Fix code style warnings in satellite .NET projects

This commit is contained in:
YoshiRulz 2024-07-07 12:38:06 +10:00
parent c93a0f9d1b
commit 479f151bbb
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
15 changed files with 22 additions and 10 deletions

View File

@ -367,6 +367,8 @@ dotnet_diagnostic.MEN013.severity = silent
dotnet_diagnostic.MEN014.severity = warning
# Use Preferred Terms
dotnet_diagnostic.MEN015.severity = silent
# Use object-oriented methods instead of top-level statements
dotnet_diagnostic.MEN016.severity = silent
## StyleCop spacing rules

View File

@ -141,7 +141,9 @@ namespace Jellyfish.Virtu
Reset = 2305843009213693952UL,
}
#pragma warning disable MA0104 // unlikely to conflict with System.Windows.Input.Keyboard
public sealed class Keyboard
#pragma warning restore MA0104
{
static Keyboard()
{

View File

@ -50,7 +50,8 @@ public sealed class FeatureNotImplementedAnalyzer : DiagnosticAnalyzer
// else correct usage, do not flag
}
bool IncludesFNIAttribute(SyntaxList<AttributeListSyntax> mds)
=> mds.SelectMany(static als => als.Attributes).Any(aSyn => featureNotImplementedAttrSym.Matches(snac.SemanticModel.GetTypeInfo(aSyn).Type));
=> mds.SelectMany(static als => als.Attributes)
.Any(aSyn => featureNotImplementedAttrSym.Matches(snac.SemanticModel.GetTypeInfo(aSyn, snac.CancellationToken).Type));
void CheckBlockBody(BlockSyntax bs, Location location)
{
if (bs.Statements.Count is not 1) snac.ReportDiagnostic(Diagnostic.Create(DiagShouldThrowNIE, location, ERR_MSG_DOES_NOT_THROW));

View File

@ -43,7 +43,9 @@ public sealed class FirstOrDefaultOnStructAnalyzer : DiagnosticAnalyzer
var operation = (IInvocationOperation) oac.Operation;
var calledSym = operation.TargetMethod.ConstructedFrom;
if (!(firstOrDefaultWithPredSym!.Matches(calledSym) || firstOrDefaultNoPredSym!.Matches(calledSym))) return;
var receiverExprType = operation.SemanticModel!.GetTypeInfo((CSharpSyntaxNode) operation.Arguments[0].Syntax).ConvertedType!;
var receiverExprType = operation.SemanticModel!.GetTypeInfo(
(CSharpSyntaxNode) operation.Arguments[0].Syntax,
oac.CancellationToken).ConvertedType!;
var collectionElemType = receiverExprType switch
{
INamedTypeSymbol nts => nts.TypeArguments[0],

View File

@ -128,7 +128,9 @@ public class HawkSourceAnalyzer : DiagnosticAnalyzer
case AnonymousObjectCreationExpressionSyntax:
snac.ReportDiagnostic(Diagnostic.Create(DiagNoAnonClasses, snac.Node.GetLocation()));
break;
case AssignmentExpressionSyntax aes when IsDiscard(aes) && snac.SemanticModel.GetSymbolInfo(aes.Right).Symbol?.Kind is SymbolKind.Local:
case AssignmentExpressionSyntax aes:
if (!IsDiscard(aes)) break;
if (snac.SemanticModel.GetSymbolInfo(aes.Right, snac.CancellationToken).Symbol?.Kind is not SymbolKind.Local) break;
snac.ReportDiagnostic(Diagnostic.Create(DiagNoDiscardingLocals, snac.Node.GetLocation()));
break;
case CollectionExpressionSyntax ces:

View File

@ -52,7 +52,7 @@ public sealed class UseNameofOperatorAnalyzer : DiagnosticAnalyzer
snac.ReportDiagnostic(Diagnostic.Create(DiagNoToStringOnType, toes.GetLocation(), toes.Type.GetText(), " in string interpolation"));
break;
case MemberAccessExpressionSyntax maes1:
var accessed = snac.SemanticModel.GetSymbolInfo(maes1.Name).Symbol;
var accessed = snac.SemanticModel.GetSymbolInfo(maes1.Name, snac.CancellationToken).Symbol;
if (memberInfoDotNameSym.Matches(accessed))
{
snac.ReportDiagnostic(Diagnostic.Create(DiagUseNameof, maes1.GetLocation(), toes.Type.GetText()));

View File

@ -42,7 +42,9 @@ public sealed class UseTypeofOperatorAnalyzer : DiagnosticAnalyzer
objectDotGetTypeSym ??= oac.Compilation.GetTypeByMetadataName("System.Object")!.GetMembers("GetType")[0];
if (!objectDotGetTypeSym.Matches(operation.TargetMethod)) return;
if (operation.Instance.Syntax is not ThisExpressionSyntax and not IdentifierNameSyntax { Identifier.Text: "GetType" }) return; // called on something that isn't `this`
var enclosingType = operation.SemanticModel!.GetDeclaredSymbol(((CSharpSyntaxNode) operation.Syntax).EnclosingTypeDeclarationSyntax()!)!;
var enclosingType = operation.SemanticModel!.GetDeclaredSymbol(
((CSharpSyntaxNode) operation.Syntax).EnclosingTypeDeclarationSyntax()!,
oac.CancellationToken)!;
oac.ReportDiagnostic(Diagnostic.Create(enclosingType.IsSealed ? DiagNoGetTypeOnThisSealed : DiagNoGetTypeOnThis, operation.Syntax.GetLocation(), enclosingType.Name));
},
OperationKind.Invocation);

View File

@ -99,7 +99,7 @@ namespace BizHawk.Common
if (cds.AttributeLists.SelectMany(e => e.Attributes)
.Any(e => e.Name.NormalizeWhitespace().ToFullString() == "CoreSettings"))
{
var symbol = semanticModel.GetDeclaredSymbol(cds);
var symbol = semanticModel.GetDeclaredSymbol(cds, context.CancellationToken);
if (symbol is not null) // probably never happens?
{
CreateDefaultSetter(source, symbol);

View File

@ -22,7 +22,7 @@
</PropertyGroup>
<PropertyGroup>
<NoWarn>$(NoWarn);IDE0005</NoWarn>
<NoWarn>$(NoWarn);IDE0005;SA1514</NoWarn>
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

View File

@ -4,6 +4,7 @@
</PropertyGroup>
<Import Project="../LibCommon.props" />
<PropertyGroup>
<NoWarn>$(NoWarn);MA0060;SA1514</NoWarn> <!-- MA0060 is for implicitly discarded Stream.Read return value and should really be fixed; SA1514 is a harmless lint rule -->
<Nullable>disable</Nullable>
</PropertyGroup>
</Project>

View File

@ -122,7 +122,7 @@ namespace BizHawk.DATTool
string a = RemoveUnneededOptions(nameString);
// process data contained in ()
string[] d = a.ToString().Split('(', ')');
var d = a.Split('(', ')');
if (d.Length > 0)
{

View File

@ -128,7 +128,7 @@ namespace BizHawk.DATTool
string a = RemoveUnneededOptions(nameString);
// process data contained in ()
string[] d = a.ToString().Split('(', ')');
var d = a.Split('(', ')');
if (d.Length > 0)
{

View File

@ -63,7 +63,7 @@ namespace BizHawk.DBManTool
// parse out modifiers
var mods = new List<string>();
modifiers = modifiers.Replace(")", ";").Replace("]",";");
modifiers = modifiers.Replace(')', ';').Replace(']', ';');
modifiers = modifiers.Replace("(", "").Replace("[", "");
var m_ = modifiers.Split(';');
foreach (var mi in m_)

Binary file not shown.