-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Filter out CompilerFeatureRequired and Obsolete attribute from method symbols #78313
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -641,7 +641,26 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE | |
| If Not _packedFlags.IsCustomAttributesPopulated Then | ||
| Dim attributeData As ImmutableArray(Of VisualBasicAttributeData) = Nothing | ||
| Dim containingPEModuleSymbol = DirectCast(ContainingModule(), PEModuleSymbol) | ||
| containingPEModuleSymbol.LoadCustomAttributes(Me.Handle, attributeData) | ||
| Dim checkForRequiredMembers = MethodKind = MethodKind.Constructor AndAlso | ||
| HasSetsRequiredMembers = False AndAlso | ||
| (Me.ContainingType.HasAnyDeclaredRequiredMembers OrElse Not Me.ContainingType.AllRequiredMembers.IsEmpty) | ||
|
|
||
| If checkForRequiredMembers Then | ||
| Dim compilerFeatureRequiredDiagnostic As DiagnosticInfo = Nothing | ||
| DeriveCompilerFeatureRequiredUseSiteInfo(compilerFeatureRequiredDiagnostic) | ||
|
|
||
| Dim discard1 As CustomAttributeHandle = Nothing | ||
| Dim discard2 As CustomAttributeHandle = Nothing | ||
| attributeData = containingPEModuleSymbol.GetCustomAttributesForToken( | ||
| Me.Handle, | ||
| filteredOutAttribute1:=discard1, | ||
| filterOut1:=If(compilerFeatureRequiredDiagnostic Is Nothing, AttributeDescription.CompilerFeatureRequiredAttribute, Nothing), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I didn't cook up some invalid IL test here. If you'd prefer that I do so, I can.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we have a test for C#, it feels like it shouldn't be very hard to port it.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We didn't, but now we do. |
||
| filteredOutAttribute2:=discard2, | ||
| filterOut2:=If(ObsoleteAttributeData Is Nothing, AttributeDescription.ObsoleteAttribute, Nothing)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| Else | ||
| containingPEModuleSymbol.LoadCustomAttributes(Me.Handle, attributeData) | ||
| End If | ||
| Debug.Assert(Not attributeData.IsDefault) | ||
| If Not attributeData.IsEmpty Then | ||
| attributeData = InterlockedOperations.Initialize(AccessUncommonFields()._lazyCustomAttributes, attributeData) | ||
|
|
||
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.
See https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEMethodSymbol.cs#L1012-L1030 for the equivalent C# version of this. I based this logic on the current C# code.