Skip to content

Commit

Permalink
Fix code style warnings in satellite .NET projects
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed Jul 7, 2024
1 parent c93a0f9 commit 479f151
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .global.editorconfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions ExternalCoreProjects/Virtu/Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ internal enum Keys : ulong
Reset = 2305843009213693952UL,
}

#pragma warning disable MA0104 // unlikely to conflict with System.Windows.Input.Keyboard
public sealed class Keyboard
#pragma warning restore MA0104
{
static Keyboard()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ void MaybeReportFor(ITypeSymbol? thrownExceptionType, Location location)
// 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public override void Initialize(AnalysisContext context)
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],
Expand Down
4 changes: 3 additions & 1 deletion ExternalProjects/BizHawk.Analyzer/HawkSourceAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ static bool IsDiscard(AssignmentExpressionSyntax aes)
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override void Initialize(AnalysisContext context)
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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public override void Initialize(AnalysisContext context)
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static partial class SettingsUtil
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);
Expand Down
2 changes: 1 addition & 1 deletion ExternalProjects/NLua/NLua.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</PropertyGroup>

<PropertyGroup>
<NoWarn>$(NoWarn);IDE0005</NoWarn>
<NoWarn>$(NoWarn);IDE0005;SA1514</NoWarn>
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions ExternalProjects/iso-parser/ISOParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
2 changes: 1 addition & 1 deletion ExternalToolProjects/DATParser/NOINTROParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void ParseNOINTROFlags(GameDB g)
string a = RemoveUnneededOptions(nameString);

// process data contained in ()
string[] d = a.ToString().Split('(', ')');
var d = a.Split('(', ')');

if (d.Length > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion ExternalToolProjects/DATParser/TOSECParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void ParseTOSECFlags(GameDB g)
string a = RemoveUnneededOptions(nameString);

// process data contained in ()
string[] d = a.ToString().Split('(', ')');
var d = a.Split('(', ')');

if (d.Length > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion ExternalToolProjects/DBMan/RomHasher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static InitialRomInfo GenerateRomHashDirect(string file, byte[] filebytes)

// 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_)
Expand Down
Binary file modified References/BizHawk.Analyzer.dll
Binary file not shown.
Binary file modified References/BizHawk.SrcGen.SettingsUtil.dll
Binary file not shown.

0 comments on commit 479f151

Please sign in to comment.