-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Local function GetAttributes #39135
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
Local function GetAttributes #39135
Conversation
…utes' into features/local-function-attributes
| private void ReportAttributesDisallowed(SyntaxList<AttributeListSyntax> attributes, DiagnosticBag diagnostics) | ||
| { | ||
| foreach (var attrList in attributes) | ||
| var diagnosticInfo = MessageID.IDS_FeatureLocalFunctionAttributes.GetFeatureAvailabilityDiagnosticInfoOpt(ScopeBinder.Compilation); |
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.
ScopeBinder.Compilation [](start = 118, length = 23)
Consider using DeclaringCompilation instead for consistency with other uses. #Resolved
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.
So, this needs a look, because DeclaringCompilation is null for some reason in EE scenarios. Perhaps that is a bug? #Resolved
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.
filed #39165 to follow up on this. #Resolved
| return lazyCustomAttributesBag.Attributes; | ||
| } | ||
|
|
||
| var bagCreatedOnThisThread = LoadAndValidateAttributes(OneOrMany.Create(_syntax.AttributeLists), ref _lazyCustomAttributesBag); |
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.
var bagCreatedOnThisThread = [](start = 12, length = 28)
Consider using _ = or ignore the return value completely.
To the comment below, there shouldn't be anything else to do for the thread that succeeds.
Same comments for GetReturnTypeAttributes. #Resolved
| public override ImmutableArray<CSharpAttributeData> GetAttributes() | ||
| { | ||
| var lazyCustomAttributesBag = _lazyCustomAttributesBag; | ||
| if (lazyCustomAttributesBag != null) |
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.
!= null [](start = 40, length = 7)
Consider using == null and moving LoadAndValidateAttributes inside the if, so there's only one return statement. Same for GetReturnTypeAttributes. #Resolved
| //Assert.Single(attributes); | ||
| Assert.Single(attributes); | ||
|
|
||
| var attributeData = attributes[0]; |
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.
Minor point: these could be combined in each of these tests.
var attributeData = attributes.Single(); #Resolved
| var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular); | ||
| compilation.GetDiagnostics().Where(d => d.Code != (int)ErrorCode.ERR_AttributesInLocalFuncDecl).Verify( | ||
| var compilation = CreateCompilationWithMscorlib45(source, options: TestOptions.DebugExe, parseOptions: TestOptions.RegularPreview); | ||
| compilation.GetDiagnostics().Verify( |
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.
GetDiagnostics().Verify [](start = 24, length = 23)
VerifyDiagnostics #Resolved
|
Could I get a second review please? @dotnet/roslyn-compiler |
…utes' into features/local-function-attributes
8e62aab to
a0427da
Compare
|
I'm not seeing a test that confirms this is blocked in an older language version. Am I missing it? #Resolved |
|
The GitHub diff seems to be hiding it, but it's here:
|
|
Could I get a second review please @dotnet/roslyn-compiler |
src/Compilers/CSharp/Test/Semantic/Semantics/LocalFunctionTests.cs
Outdated
Show resolved
Hide resolved
chsienki
left a comment
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.
![]()
Related to #38801
- [ ] tests for speculative semantic modelmoving to test planPTAL @dotnet/roslyn-compiler @cston