Skip to content

Conversation

@RikkiGibson
Copy link
Member

@RikkiGibson RikkiGibson commented Oct 8, 2019

Related to #38801

  • LangVersion errors on all local function attributes (incl. parameters and type parameters)
  • GetAttributes()
  • Attribute binding, rejecting attributes on invalid targets
    - [ ] tests for speculative semantic model moving to test plan

PTAL @dotnet/roslyn-compiler @cston

@RikkiGibson RikkiGibson added this to the Compiler.Next milestone Oct 8, 2019
@RikkiGibson RikkiGibson requested a review from a team as a code owner October 8, 2019 18:28
private void ReportAttributesDisallowed(SyntaxList<AttributeListSyntax> attributes, DiagnosticBag diagnostics)
{
foreach (var attrList in attributes)
var diagnosticInfo = MessageID.IDS_FeatureLocalFunctionAttributes.GetFeatureAvailabilityDiagnosticInfoOpt(ScopeBinder.Compilation);
Copy link
Contributor

@cston cston Oct 9, 2019

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

Copy link
Member Author

@RikkiGibson RikkiGibson Oct 9, 2019

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

Copy link
Member Author

@RikkiGibson RikkiGibson Oct 9, 2019

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);
Copy link
Contributor

@cston cston Oct 9, 2019

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)
Copy link
Contributor

@cston cston Oct 9, 2019

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];
Copy link
Contributor

@cston cston Oct 9, 2019

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(
Copy link
Contributor

@cston cston Oct 9, 2019

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

@RikkiGibson RikkiGibson requested a review from a team October 9, 2019 20:59
@RikkiGibson
Copy link
Member Author

Could I get a second review please? @dotnet/roslyn-compiler

@RikkiGibson RikkiGibson requested review from a team and srivatsn as code owners October 9, 2019 21:32
@RikkiGibson RikkiGibson force-pushed the features/local-function-attributes branch from 8e62aab to a0427da Compare October 9, 2019 22:20
@agocke
Copy link
Member

agocke commented Oct 10, 2019

I'm not seeing a test that confirms this is blocked in an older language version. Am I missing it? #Resolved

@RikkiGibson
Copy link
Member Author

RikkiGibson commented Oct 10, 2019

The GitHub diff seems to be hiding it, but it's here:

public void LocalFunctionAttribute_LangVersionError()
#Resolved

@RikkiGibson RikkiGibson removed request for a team and srivatsn October 10, 2019 21:29
@RikkiGibson
Copy link
Member Author

Could I get a second review please @dotnet/roslyn-compiler

Copy link
Member

@chsienki chsienki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@RikkiGibson RikkiGibson merged commit df8d805 into dotnet:features/local-function-attributes Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants