Skip to content
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

Disallow module initializers in VB #44227

Merged
merged 4 commits into from
May 15, 2020

Conversation

RikkiGibson
Copy link
Contributor

@RikkiGibson RikkiGibson commented May 13, 2020

Related to #40500

Module initializers are not supported in VB. See #43281 (comment)

Tests are heavily based on the SkipLocalsInit tests in VB.

@RikkiGibson RikkiGibson requested a review from a team as a code owner May 13, 2020 20:57
@@ -198,6 +198,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If arguments.Attribute.IsTargetAttribute(Me, AttributeDescription.SkipLocalsInitAttribute) Then
arguments.Diagnostics.Add(ERRID.WRN_AttributeNotSupportedInVB, arguments.AttributeSyntaxOpt.Location, AttributeDescription.SkipLocalsInitAttribute.FullName)
End If

If arguments.Attribute.IsTargetAttribute(Me, AttributeDescription.ModuleInitializerAttribute) Then
Copy link
Contributor

@AlekseyTs AlekseyTs May 14, 2020

Choose a reason for hiding this comment

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

arguments.Attribute.IsTargetAttribute(Me, AttributeDescription.ModuleInitializerAttribute) [](start = 15, length = 90)

Should we limit this check to MethodSymbols? If I remember correctly C# ignores the attribute on anything, but a method. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think that would be more consistent.

@AlekseyTs
Copy link
Contributor

AlekseyTs commented May 14, 2020

Done with review pass (iteration 2) #Closed

@@ -1572,6 +1572,10 @@ lReportErrorOnTwoTokens:
arguments.Diagnostics.Add(ERRID.ERR_ExplicitTupleElementNamesAttribute, arguments.AttributeSyntaxOpt.Location)
End If

If arguments.Attribute.IsTargetAttribute(Me, AttributeDescription.ModuleInitializerAttribute) Then
Copy link
Contributor

@AlekseyTs AlekseyTs May 14, 2020

Choose a reason for hiding this comment

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

If arguments.Attribute.IsTargetAttribute(Me, AttributeDescription.ModuleInitializerAttribute) [](start = 12, length = 93)

It looks like this check should be moved into DecodeWellKnownAttributeAppliedToMethod. Please add a test with the attribute applied to a return. #Closed


Dim comp = CreateCompilationWithMscorlib40(source)

CompilationUtils.AssertTheseDiagnostics(comp, <expected></expected>)
Copy link
Contributor

@AlekseyTs AlekseyTs May 14, 2020

Choose a reason for hiding this comment

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

AssertTheseDiagnostics [](start = 29, length = 22)

AssertNoDiagnostics? To avoid creating dummy XML elements. #Closed

@AlekseyTs
Copy link
Contributor

AlekseyTs commented May 14, 2020

Done with review pass (iteration 3) #Closed

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (iteration 4)

@RikkiGibson RikkiGibson merged commit 3790b6b into dotnet:features/module-initializers May 15, 2020
@RikkiGibson RikkiGibson deleted the mi-vb branch May 15, 2020 16:48
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.

3 participants