diff --git a/ExternalProjects/BizHawk.Analyzer/BizHawk.Analyzer.csproj b/ExternalProjects/BizHawk.Analyzer/BizHawk.Analyzer.csproj index 46dbd2596a..922654eb79 100644 --- a/ExternalProjects/BizHawk.Analyzer/BizHawk.Analyzer.csproj +++ b/ExternalProjects/BizHawk.Analyzer/BizHawk.Analyzer.csproj @@ -3,4 +3,7 @@ netstandard2.0 + + + diff --git a/ExternalProjects/BizHawk.Analyzer/FeatureNotImplementedAnalyzer.cs b/ExternalProjects/BizHawk.Analyzer/FeatureNotImplementedAnalyzer.cs index f4cf5fb505..60c87cfe39 100644 --- a/ExternalProjects/BizHawk.Analyzer/FeatureNotImplementedAnalyzer.cs +++ b/ExternalProjects/BizHawk.Analyzer/FeatureNotImplementedAnalyzer.cs @@ -49,14 +49,13 @@ public sealed class FeatureNotImplementedAnalyzer : DiagnosticAnalyzer .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)); - else if (bs.Statements[0] is not ThrowStatementSyntax tss) snac.ReportDiagnostic(Diagnostic.Create(DiagShouldThrowNIE, location, ERR_MSG_DOES_NOT_THROW)); - else MaybeReportFor(snac.SemanticModel.GetThrownExceptionType(tss), tss.GetLocation()); + if (bs.Statements is [ ThrowStatementSyntax tss ]) MaybeReportFor(snac.SemanticModel.GetThrownExceptionType(tss), tss.GetLocation()); + else snac.ReportDiagnostic(Diagnostic.Create(DiagShouldThrowNIE, location, ERR_MSG_DOES_NOT_THROW)); } void CheckExprBody(ArrowExpressionClauseSyntax aecs, Location location) { - if (aecs.Expression is not ThrowExpressionSyntax tes) snac.ReportDiagnostic(Diagnostic.Create(DiagShouldThrowNIE, location, ERR_MSG_DOES_NOT_THROW)); - else MaybeReportFor(snac.SemanticModel.GetThrownExceptionType(tes), tes.GetLocation()); + if (aecs.Expression is ThrowExpressionSyntax tes) MaybeReportFor(snac.SemanticModel.GetThrownExceptionType(tes), tes.GetLocation()); + else snac.ReportDiagnostic(Diagnostic.Create(DiagShouldThrowNIE, location, ERR_MSG_DOES_NOT_THROW)); } void CheckAccessor(AccessorDeclarationSyntax ads) { diff --git a/ExternalProjects/BizHawk.Analyzer/HawkSourceAnalyzer.cs b/ExternalProjects/BizHawk.Analyzer/HawkSourceAnalyzer.cs index 63fc98a0cb..3a4938b3b7 100644 --- a/ExternalProjects/BizHawk.Analyzer/HawkSourceAnalyzer.cs +++ b/ExternalProjects/BizHawk.Analyzer/HawkSourceAnalyzer.cs @@ -150,8 +150,8 @@ public class HawkSourceAnalyzer : DiagnosticAnalyzer case QueryExpressionSyntax: snac.ReportDiagnostic(Diagnostic.Create(DiagNoQueryExpression, snac.Node.GetLocation())); break; - case RecordDeclarationSyntax rds: - if (!rds.ClassOrStructKeyword.ToFullString().Contains("class")) snac.ReportDiagnostic(Diagnostic.Create(DiagRecordImplicitlyRefType, rds.GetLocation())); + case RecordDeclarationSyntax rds when rds.ClassOrStructKeyword.ToString() is not "class": // `record struct`s don't use this kind + snac.ReportDiagnostic(Diagnostic.Create(DiagRecordImplicitlyRefType, rds.GetLocation())); break; case SwitchExpressionArmSyntax { WhenClause: null, Pattern: DiscardPatternSyntax, Expression: ThrowExpressionSyntax tes }: var thrownExceptionType = snac.SemanticModel.GetThrownExceptionType(tes); diff --git a/ExternalProjects/BizHawk.Analyzer/UseNameofOperatorAnalyzer.cs b/ExternalProjects/BizHawk.Analyzer/UseNameofOperatorAnalyzer.cs index 6d0bebe4e3..3ebf94a453 100644 --- a/ExternalProjects/BizHawk.Analyzer/UseNameofOperatorAnalyzer.cs +++ b/ExternalProjects/BizHawk.Analyzer/UseNameofOperatorAnalyzer.cs @@ -33,7 +33,8 @@ public sealed class UseNameofOperatorAnalyzer : DiagnosticAnalyzer snac => { memberInfoDotNameSym ??= snac.Compilation.GetTypeByMetadataName("System.Reflection.MemberInfo")!.GetMembers("Name")[0]; - typeDotToStringSym ??= snac.Compilation.GetTypeByMetadataName("System.Type")!.GetMembers("ToString")[0]; + typeDotToStringSym ??= snac.Compilation.GetTypeByMetadataName("System.Type")! + .GetMembers(WellKnownMemberNames.ObjectToString)[0]; var toes = (TypeOfExpressionSyntax) snac.Node; switch (toes.Parent) {