Skip to content

Commit

Permalink
fix: strdiag001 on file scoped classes (#2309)
Browse files Browse the repository at this point in the history
Co-authored-by: IXLLEGACYIXL <ixllegacy123@outlook.com>
  • Loading branch information
IXLLEGACYIXL and IXLLEGACYIXL committed Jun 7, 2024
1 parent c1b36e1 commit 8b07e0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public void No_Error_On_Private_Inner_Class_without_DataContract()
string sourceCode = string.Format(ClassTemplates.BasicClassTemplate, "private class InnerClass { }");
TestHelper.ExpectNoDiagnosticsErrors(sourceCode);
}
// TODO: Enable with .NET8 merge as we need a higher C# version
[Fact(Skip = "file scoped classes won't compile")]
[Fact]
public void Error_On_file_scope_Class_with_DataContract()
{
string sourceCode = "using Stride.Core; [DataContract] file class FileScopeClass { }";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context, INamedTypeSymbo
if (!symbol.HasAttribute(dataContractAttribute))
return;

if(!symbol.IsVisibleToSerializer(hasDataMemberAttribute: true))
if (symbol.IsFileLocal)
Rule.ReportDiagnostics(context, symbol);

if (!symbol.IsVisibleToSerializer(hasDataMemberAttribute: true))
Rule.ReportDiagnostics(context, symbol);
}
}

0 comments on commit 8b07e0b

Please sign in to comment.