@@ -12,7 +12,9 @@ public class PublicProgramSourceGenerator : IIncrementalGenerator
1212{
1313 private const string PublicPartialProgramClassSource = """
1414// <auto-generated />
15+ #pragma warning disable CS1591
1516public partial class Program { }
17+ #pragma warning restore CS1591
1618""" ;
1719
1820 public void Initialize ( IncrementalGeneratorInitializationContext context )
@@ -21,16 +23,16 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
2123 // Get the entry point associated with the compilation, this maps to the Main method definition
2224 // Get the containing symbol of the entry point, this maps to the Program class
2325 compilation . GetEntryPoint ( cancellationToken ) ? . ContainingSymbol is INamedTypeSymbol
24- {
25- // If the discovered `Program` type is not a class then its not
26- // generated and has been defined in source, so we can skip it
27- // If the program class is already public, we don't need to generate anything.
28- DeclaredAccessibility : not Accessibility . Public ,
29- TypeKind : TypeKind . Class ,
30- // If there are multiple partial declarations, then do nothing since we don't want
31- // to trample on visibility explicitly set by the user
32- DeclaringSyntaxReferences : { Length : 1 } declaringSyntaxReferences
33- } &&
26+ {
27+ // If the discovered `Program` type is not a class then its not
28+ // generated and has been defined in source, so we can skip it
29+ // If the program class is already public, we don't need to generate anything.
30+ DeclaredAccessibility : not Accessibility . Public ,
31+ TypeKind : TypeKind . Class ,
32+ // If there are multiple partial declarations, then do nothing since we don't want
33+ // to trample on visibility explicitly set by the user
34+ DeclaringSyntaxReferences : { Length : 1 } declaringSyntaxReferences
35+ } &&
3436 // If the `Program` class is already declared in user code, we don't need to generate anything.
3537 declaringSyntaxReferences . Single ( ) . GetSyntax ( cancellationToken ) is not ClassDeclarationSyntax
3638 ) ;
0 commit comments