Disallow module initializers in VB#44227
Disallow module initializers in VB#44227RikkiGibson merged 4 commits intodotnet:features/module-initializersfrom
Conversation
| arguments.Diagnostics.Add(ERRID.WRN_AttributeNotSupportedInVB, arguments.AttributeSyntaxOpt.Location, AttributeDescription.SkipLocalsInitAttribute.FullName) | ||
| End If | ||
|
|
||
| If arguments.Attribute.IsTargetAttribute(Me, AttributeDescription.ModuleInitializerAttribute) Then |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Yes, I think that would be more consistent.
|
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 |
There was a problem hiding this comment.
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>) |
There was a problem hiding this comment.
AssertTheseDiagnostics [](start = 29, length = 22)
AssertNoDiagnostics? To avoid creating dummy XML elements. #Closed
|
Done with review pass (iteration 3) #Closed |
Related to #40500
Module initializers are not supported in VB. See #43281 (comment)
Tests are heavily based on the SkipLocalsInit tests in VB.