Skip to content

Disallow module initializers in VB#44227

Merged
RikkiGibson merged 4 commits intodotnet:features/module-initializersfrom
RikkiGibson:mi-vb
May 15, 2020
Merged

Disallow module initializers in VB#44227
RikkiGibson merged 4 commits intodotnet:features/module-initializersfrom
RikkiGibson:mi-vb

Conversation

@RikkiGibson
Copy link
Member

@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
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
Member 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

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