Fix some analyzer warnings

also improve globalconfig readability
This commit is contained in:
Morilli 2023-11-03 11:56:23 +01:00
parent cdf89f4b09
commit 7d4b21f9c7
11 changed files with 74 additions and 72 deletions

View File

@ -1,18 +1,29 @@
is_global = true
# Globalization rules
dotnet_code_quality.CA1305.excluded_symbol_names = T:System.Byte|T:System.SByte|T:System.Int16|T:System.UInt16|T:System.Int32|T:System.UInt32|T:System.Int64|T:System.UInt64|T:System.String|T:System.Text.StringBuilder|T:System.Convert
## Globalization rules
# Specify IFormatProvider
dotnet_diagnostic.CA1305.severity = error
dotnet_code_quality.CA1305.excluded_symbol_names = T:System.Byte|T:System.SByte|T:System.Int16|T:System.UInt16|T:System.Int32|T:System.UInt32|T:System.Int64|T:System.UInt64|T:System.String|T:System.Text.StringBuilder|T:System.Convert
# Specify marshalling for P/Invoke string arguments
dotnet_diagnostic.CA2101.severity = suggestion
# Performance rules
dotnet_code_quality.CA1826.exclude_ordefault_methods = true
## Performance rules
# Do not initialize unnecessarily
dotnet_diagnostic.CA1805.severity = silent
# Mark members as static
dotnet_diagnostic.CA1822.severity = silent
# Use property instead of Linq Enumerable method
dotnet_code_quality.CA1826.exclude_ordefault_methods = true
# Avoid StringBuilder parameters for P/Invokes
dotnet_diagnostic.CA1838.severity = suggestion
# Usage rules
## Usage rules
# Call GC.SuppressFinalize correctly
dotnet_diagnostic.CA1816.severity = none
# Do not raise reserved exception types
dotnet_diagnostic.CA2201.severity = suggestion
# Implement serialization constructors
dotnet_diagnostic.CA2229.severity = silent

View File

@ -461,10 +461,6 @@
<!-- Use the Regex source generator -->
<Rule Id="MA0110" Action="Error" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.FxCopAnalyzers">
<!-- Implement serialization constructors -->
<Rule Id="CA2229" Action="Hidden" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.SpacingRules">
<!-- Keywords should be spaced correctly -->
<Rule Id="SA1000" Action="Hidden" />

View File

@ -0,0 +1,2 @@
[*.cs]
csharp_using_directive_placement = inside_namespace

View File

@ -10,9 +10,10 @@
<Import Project="LibCommon.props" />
<PropertyGroup>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<NoWarn>$(NoWarn)IDE0065;RS2008</NoWarn>
<NoWarn>$(NoWarn);RS2008</NoWarn>
</PropertyGroup>
<ItemGroup>
<EditorConfigFiles Include="$(MSBuildProjectDirectory)/../Analyzers.editorconfig" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.0" />
<Compile Include="$(MSBuildProjectDirectory)/../AnalyzersCommon/**/*.cs" />

View File

@ -1,3 +1,5 @@
namespace BizHawk.SrcGen.ReflectionCache;
using System;
using System.Collections.Generic;
using System.Linq;
@ -7,11 +9,9 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
namespace BizHawk.SrcGen.ReflectionCache
[Generator]
public sealed class ReflectionCacheGenerator : ISourceGenerator
{
[Generator]
public sealed class ReflectionCacheGenerator : ISourceGenerator
{
private sealed class ReflectionCacheGenSyntaxReceiver : ISyntaxReceiver
{
/// <remarks>
@ -105,5 +105,4 @@ namespace {nSpace}
";
context.AddSource("ReflectionCache.cs", SourceText.From(src, Encoding.UTF8));
}
}
}

View File

@ -1,11 +1,11 @@
using System;
namespace BizHawk.SrcGen.VersionInfo;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
namespace BizHawk.SrcGen.VersionInfo;
[Generator]
public class VersionInfoGenerator : ISourceGenerator
{

View File

@ -1,6 +1,4 @@
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Client.EmuHawk
{
public partial class TAStudio : IControlMainform
{

View File

@ -1,6 +1,5 @@
#nullable disable
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;

View File

@ -1,5 +1,3 @@
using System;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS

View File

@ -2,7 +2,6 @@ using System;
using System.Runtime.InteropServices;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS
{

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using BizHawk.BizInvoke;
using BizHawk.Emulation.Common;
using NymaTypes;