mirror of https://github.com/dotnet/runtime
Update dependencies from dotnet/roslyn-analyzers, config new analyzers (#99343)
* Reapply "[main] Update dependencies from dotnet/roslyn-analyzers (#98984)" (#99327) * Configure new analyzers severity in src and test projects * Fix some of CA2263 warnings
This commit is contained in:
parent
c806bf6970
commit
c6906ae608
|
@ -274,6 +274,12 @@ dotnet_diagnostic.CA1512.severity = warning
|
|||
# CA1513: Use ObjectDisposedException throw helper
|
||||
dotnet_diagnostic.CA1513.severity = warning
|
||||
|
||||
# CA1514: Avoid redundant length argument
|
||||
dotnet_diagnostic.CA1514.severity = warning
|
||||
|
||||
# CA1515: Consider making public types internal
|
||||
dotnet_diagnostic.CA1515.severity = none
|
||||
|
||||
# CA1700: Do not name enum values 'Reserved'
|
||||
dotnet_diagnostic.CA1700.severity = none
|
||||
|
||||
|
@ -492,6 +498,9 @@ dotnet_diagnostic.CA1869.severity = warning
|
|||
# CA1870: Use a cached 'SearchValues' instance
|
||||
dotnet_diagnostic.CA1870.severity = warning
|
||||
|
||||
# CA1871: Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull'
|
||||
dotnet_diagnostic.CA1871.severity = warning
|
||||
|
||||
# CA2000: Dispose objects before losing scope
|
||||
dotnet_diagnostic.CA2000.severity = none
|
||||
|
||||
|
@ -679,6 +688,18 @@ dotnet_diagnostic.CA2260.severity = warning
|
|||
# CA2261: Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
|
||||
dotnet_diagnostic.CA2261.severity = warning
|
||||
|
||||
# CA2262: Set 'MaxResponseHeadersLength' properly
|
||||
dotnet_diagnostic.CA2262.severity = warning
|
||||
|
||||
# CA2263: Prefer generic overload when type is known
|
||||
dotnet_diagnostic.CA2263.severity = info
|
||||
|
||||
# CA2264: Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull'
|
||||
dotnet_diagnostic.CA2264.severity = warning
|
||||
|
||||
# CA2265: Do not compare Span<T> to 'null' or 'default'
|
||||
dotnet_diagnostic.CA2265.severity = warning
|
||||
|
||||
# CA2300: Do not use insecure deserializer BinaryFormatter
|
||||
dotnet_diagnostic.CA2300.severity = none
|
||||
|
||||
|
|
|
@ -273,6 +273,12 @@ dotnet_diagnostic.CA1512.severity = none
|
|||
# CA1513: Use ObjectDisposedException throw helper
|
||||
dotnet_diagnostic.CA1513.severity = none
|
||||
|
||||
# CA1514: Avoid redundant length argument
|
||||
dotnet_diagnostic.CA1514.severity = none
|
||||
|
||||
# CA1515: Consider making public types internal
|
||||
dotnet_diagnostic.CA1515.severity = none
|
||||
|
||||
# CA1700: Do not name enum values 'Reserved'
|
||||
dotnet_diagnostic.CA1700.severity = none
|
||||
|
||||
|
@ -489,6 +495,9 @@ dotnet_diagnostic.CA1869.severity = none
|
|||
# CA1870: Use a cached 'SearchValues' instance
|
||||
dotnet_diagnostic.CA1870.severity = none
|
||||
|
||||
# CA1871: Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull'
|
||||
dotnet_diagnostic.CA1871.severity = none
|
||||
|
||||
# CA2000: Dispose objects before losing scope
|
||||
dotnet_diagnostic.CA2000.severity = none
|
||||
|
||||
|
@ -675,6 +684,18 @@ dotnet_diagnostic.CA2260.severity = none
|
|||
# CA2261: Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
|
||||
dotnet_diagnostic.CA2261.severity = none
|
||||
|
||||
# CA2262: Set 'MaxResponseHeadersLength' properly
|
||||
dotnet_diagnostic.CA2262.severity = none
|
||||
|
||||
# CA2263: Prefer generic overload when type is known
|
||||
dotnet_diagnostic.CA2263.severity = none
|
||||
|
||||
# CA2264: Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull'
|
||||
dotnet_diagnostic.CA2264.severity = none
|
||||
|
||||
# CA2265: Do not compare Span<T> to 'null' or 'default'
|
||||
dotnet_diagnostic.CA2265.severity = none
|
||||
|
||||
# CA2300: Do not use insecure deserializer BinaryFormatter
|
||||
dotnet_diagnostic.CA2300.severity = none
|
||||
|
||||
|
|
|
@ -404,13 +404,13 @@
|
|||
<Uri>https://github.com/dotnet/roslyn</Uri>
|
||||
<Sha>77372c66fd54927312b5b0a2e399e192f74445c9</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0-beta1.24122.2">
|
||||
<Dependency Name="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0-beta1.24155.1">
|
||||
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
|
||||
<Sha>ba8b7f2c3ae092d0301f0c5e49bd30340af553c8</Sha>
|
||||
<Sha>628d239421a3ae54464c60901fd9b831b3f01efa</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0-preview.24122.2">
|
||||
<Dependency Name="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0-preview.24155.1">
|
||||
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
|
||||
<Sha>ba8b7f2c3ae092d0301f0c5e49bd30340af553c8</Sha>
|
||||
<Sha>628d239421a3ae54464c60901fd9b831b3f01efa</Sha>
|
||||
</Dependency>
|
||||
<!-- Intermediate is necessary for source build. -->
|
||||
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.10.0-2.24114.13">
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<!-- dotnet/roslyn-analyzers dependencies -->
|
||||
<MicrosoftCodeAnalysisAnalyzersVersion>3.11.0-beta1.24122.2</MicrosoftCodeAnalysisAnalyzersVersion>
|
||||
<MicrosoftCodeAnalysisNetAnalyzersVersion>9.0.0-preview.24122.2</MicrosoftCodeAnalysisNetAnalyzersVersion>
|
||||
<MicrosoftCodeAnalysisAnalyzersVersion>3.11.0-beta1.24155.1</MicrosoftCodeAnalysisAnalyzersVersion>
|
||||
<MicrosoftCodeAnalysisNetAnalyzersVersion>9.0.0-preview.24155.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
|
||||
<!-- dotnet/roslyn dependencies -->
|
||||
<!--
|
||||
These versions should not be used by any project that contributes to the design-time experience in VS, such as an analyzer, code-fix, or generator assembly.
|
||||
|
|
|
@ -175,7 +175,7 @@ namespace ILCompiler
|
|||
private static Dictionary<TargetArchitecture, Dictionary<string, InstructionSet>> ComputeInstructionSetSupport()
|
||||
{
|
||||
var supportMatrix = new Dictionary<TargetArchitecture, Dictionary<string, InstructionSet>>();
|
||||
foreach (TargetArchitecture arch in Enum.GetValues(typeof(TargetArchitecture)))
|
||||
foreach (TargetArchitecture arch in Enum.GetValues<TargetArchitecture>())
|
||||
{
|
||||
supportMatrix[arch] = ComputeInstructSetSupportForArch(arch);
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ namespace ILCompiler
|
|||
private static Dictionary<TargetArchitecture, InstructionSetFlags> ComputeNonSpecifiableInstructionSetSupport()
|
||||
{
|
||||
var matrix = new Dictionary<TargetArchitecture, InstructionSetFlags>();
|
||||
foreach (TargetArchitecture arch in Enum.GetValues(typeof(TargetArchitecture)))
|
||||
foreach (TargetArchitecture arch in Enum.GetValues<TargetArchitecture>())
|
||||
{
|
||||
matrix[arch] = ComputeNonSpecifiableInstructionSetSupportForArch(arch);
|
||||
}
|
||||
|
|
|
@ -875,7 +875,7 @@ namespace Internal.Metadata.NativeFormat.Writer
|
|||
{
|
||||
public override string ToString()
|
||||
{
|
||||
string str = Enum.GetName(typeof(MethodSemanticsAttributes), Attributes);
|
||||
string str = Enum.GetName(Attributes);
|
||||
return str + " : " + Method.ToString();
|
||||
}
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ namespace Internal.Metadata.NativeFormat.Writer
|
|||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(" ", Enum.GetName(typeof(CallingConventions), CallingConvention),
|
||||
return string.Join(" ", Enum.GetName(CallingConvention),
|
||||
Type.ToString()) + "(" + ToString(Parameters) + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -488,7 +488,11 @@ namespace System.Resources
|
|||
if (typeName.StartsWith("ResourceTypeCode.", StringComparison.Ordinal))
|
||||
{
|
||||
typeName = typeName.Substring(17); // Remove through '.'
|
||||
#if NETCOREAPP
|
||||
ResourceTypeCode typeCode = Enum.Parse<ResourceTypeCode>(typeName);
|
||||
#else
|
||||
ResourceTypeCode typeCode = (ResourceTypeCode)Enum.Parse(typeof(ResourceTypeCode), typeName);
|
||||
#endif
|
||||
return typeCode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace System.ComponentModel.DataAnnotations.Schema
|
|||
/// <param name="databaseGeneratedOption">The pattern used to generate values for the property in the database.</param>
|
||||
public DatabaseGeneratedAttribute(DatabaseGeneratedOption databaseGeneratedOption)
|
||||
{
|
||||
if (!(Enum.IsDefined(typeof(DatabaseGeneratedOption), databaseGeneratedOption)))
|
||||
if (!Enum.IsDefined(databaseGeneratedOption))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(databaseGeneratedOption));
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace System.Diagnostics
|
|||
|
||||
if (!string.IsNullOrEmpty(sourceElement.SwitchValue))
|
||||
{
|
||||
traceSource.Switch.Level = (SourceLevels)Enum.Parse(typeof(SourceLevels), sourceElement.SwitchValue);
|
||||
traceSource.Switch.Level = Enum.Parse<SourceLevels>(sourceElement.SwitchValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ namespace System.Diagnostics
|
|||
// The SwitchValue changed; just update our internalSwitch.
|
||||
if (!string.IsNullOrEmpty(sourceElement.SwitchValue))
|
||||
{
|
||||
traceSource.Switch.Level = (SourceLevels)Enum.Parse(typeof(SourceLevels), sourceElement.SwitchValue);
|
||||
traceSource.Switch.Level = Enum.Parse<SourceLevels>(sourceElement.SwitchValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace System.Diagnostics
|
|||
get => _entryType;
|
||||
set
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(EventLogEntryType), value))
|
||||
if (!Enum.IsDefined(value))
|
||||
throw new InvalidEnumArgumentException(nameof(EntryType), (int)value, typeof(EventLogEntryType));
|
||||
|
||||
_entryType = value;
|
||||
|
|
|
@ -1292,7 +1292,7 @@ namespace System.Diagnostics
|
|||
if (Source.Length == 0)
|
||||
throw new ArgumentException(SR.NeedSourceToWrite);
|
||||
|
||||
if (!Enum.IsDefined(typeof(EventLogEntryType), type))
|
||||
if (!Enum.IsDefined(type))
|
||||
throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(EventLogEntryType));
|
||||
|
||||
string currentMachineName = machineName;
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace System.Diagnostics
|
|||
}
|
||||
set
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(PerformanceCounterType), value))
|
||||
if (!Enum.IsDefined(value))
|
||||
throw new InvalidEnumArgumentException(nameof(PerformanceCounterType), (int)value, typeof(PerformanceCounterType));
|
||||
|
||||
_counterType = value;
|
||||
|
|
|
@ -5498,7 +5498,7 @@ namespace System.Diagnostics.Tracing
|
|||
if (channelInfo.Attribs != null)
|
||||
{
|
||||
EventChannelAttribute attribs = channelInfo.Attribs;
|
||||
if (Enum.IsDefined(typeof(EventChannelType), attribs.EventChannelType))
|
||||
if (Enum.IsDefined(attribs.EventChannelType))
|
||||
channelType = attribs.EventChannelType.ToString();
|
||||
enabled = attribs.Enabled;
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace System.Xml.Xsl.Qil
|
|||
foreach (QilNode n in fdecls)
|
||||
{
|
||||
// i.e. <Function id="$a"/>
|
||||
this.writer.WriteStartElement(Enum.GetName(typeof(QilNodeType), n.NodeType)!);
|
||||
this.writer.WriteStartElement(Enum.GetName(n.NodeType)!);
|
||||
this.writer.WriteAttributeString("id", _ngen.NameOf(n));
|
||||
WriteXmlType(n);
|
||||
|
||||
|
@ -277,7 +277,7 @@ namespace System.Xml.Xsl.Qil
|
|||
WriteAnnotations(node.Annotation);
|
||||
|
||||
// Call WriteStartElement
|
||||
this.writer.WriteStartElement("", Enum.GetName(typeof(QilNodeType), node.NodeType)!, "");
|
||||
this.writer.WriteStartElement("", Enum.GetName(node.NodeType)!, "");
|
||||
|
||||
// Write common attributes
|
||||
#if QIL_TRACE_NODE_CREATION
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace System.Text.RegularExpressions
|
|||
#if DEBUG
|
||||
static RegexWriter()
|
||||
{
|
||||
Debug.Assert(!Enum.IsDefined(typeof(RegexNodeKind), BeforeChild));
|
||||
Debug.Assert(!Enum.IsDefined(typeof(RegexNodeKind), AfterChild));
|
||||
Debug.Assert(!Enum.IsDefined(BeforeChild));
|
||||
Debug.Assert(!Enum.IsDefined(AfterChild));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,9 +33,7 @@ internal sealed class FileCache
|
|||
Enabled = true;
|
||||
if (File.Exists(cacheFilePath))
|
||||
{
|
||||
_oldCache = (CompilerCache?)JsonSerializer.Deserialize(File.ReadAllText(cacheFilePath),
|
||||
typeof(CompilerCache),
|
||||
s_jsonOptions);
|
||||
_oldCache = JsonSerializer.Deserialize<CompilerCache>(File.ReadAllText(cacheFilePath), s_jsonOptions);
|
||||
}
|
||||
|
||||
_oldCache ??= new();
|
||||
|
|
Loading…
Reference in New Issue