-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Main attributes for simple programs #59471
Changes from all commits
c20d0bc
ef86c9b
4e31b6d
7d10648
1c26df5
4650f06
a07f5e0
e7db199
afd2bd5
54ed6ec
1210989
8c8b787
c4788b5
6d8e593
ae81015
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
|
||
namespace Microsoft.CodeAnalysis.CSharp.Symbols | ||
{ | ||
internal sealed class SynthesizedSimpleProgramEntryPointSymbol : SourceMemberMethodSymbol | ||
internal sealed class SynthesizedSimpleProgramEntryPointSymbol : SourceMemberMethodSymbol, IAttributeTargetSymbol | ||
{ | ||
/// <summary> | ||
/// The corresponding <see cref="SingleTypeDeclaration"/>. | ||
|
@@ -281,6 +281,22 @@ internal override bool IsDefinedInSourceTree(SyntaxTree tree, TextSpan? definedW | |
|
||
public SyntaxNode ReturnTypeSyntax => CompilationUnit.Members.First(m => m.Kind() == SyntaxKind.GlobalStatement); | ||
|
||
internal override OneOrMany<SyntaxList<AttributeListSyntax>> GetAttributeDeclarations() | ||
{ | ||
// there could me multiple simple program entry points. Only consider [main:] attributes | ||
// if we're the entry point that will ultimately be selected. | ||
if (this == GetSimpleProgramEntryPoint(DeclaringCompilation)) | ||
{ | ||
return OneOrMany.Create(((SourceAssemblySymbol)ContainingAssembly).GetAttributeDeclarations()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the later filtering on these for only |
||
} | ||
|
||
return OneOrMany<SyntaxList<AttributeListSyntax>>.Empty; | ||
} | ||
|
||
protected override IAttributeTargetSymbol AttributeOwner => (IAttributeTargetSymbol)this.ContainingAssembly; | ||
|
||
AttributeLocation IAttributeTargetSymbol.DefaultAttributeLocation => AttributeLocation.Main; | ||
|
||
private static bool IsNullableAnalysisEnabled(CSharpCompilation compilation, CompilationUnitSyntax syntax) | ||
{ | ||
foreach (var member in syntax.Members) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally want to prefer doing semantic checks for these types of things if reasonable to do.