-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Ensure errors are reported when compiler is unable to emit a required attribute. #70556
Conversation
… attribute. Related to dotnet#70338.
src/Compilers/CSharp/Portable/Symbols/Attributes/AttributeData.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Jan Jones <[email protected]>
@dotnet/roslyn-compiler For the second review. |
@@ -48,7 +48,7 @@ internal abstract partial class EmbeddedTypesManager< | |||
where TModuleCompilationState : CommonModuleCompilationState | |||
where TEmbeddedTypesManager : EmbeddedTypesManager<TPEModuleBuilder, TModuleCompilationState, TEmbeddedTypesManager, TSyntaxNode, TAttributeData, TSymbol, TAssemblySymbol, TNamedTypeSymbol, TFieldSymbol, TMethodSymbol, TEventSymbol, TPropertySymbol, TParameterSymbol, TTypeParameterSymbol, TEmbeddedType, TEmbeddedField, TEmbeddedMethod, TEmbeddedEvent, TEmbeddedProperty, TEmbeddedParameter, TEmbeddedTypeParameter> | |||
where TSyntaxNode : SyntaxNode | |||
where TAttributeData : AttributeData, Cci.ICustomAttribute | |||
where TAttributeData : class, Cci.ICustomAttribute |
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.
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.
Was there a reason for this change?
Yes, I want to prevent the common component to take advantage of the APIs available from 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.
Among other things, this ensures that I adjusted all "interesting" code without creating error tests for all affected attributes.
return attributeConstructor.GetUseSiteInfo().DiagnosticInfo; | ||
|
||
case { }: | ||
return new CSDiagnosticInfo(ErrorCode.ERR_BogusType, string.Empty); |
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.
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.
AttributeClass
?
No. There is nothing wrong with the attribute class here. We simply failed to crack the attribute application, i.e. dealing with some sort of invalid metadata for the specific attribute application. In such cases elsewhere we create UnsupportedMetadataTypeSymbol
and this is how we report a use-site error for it.
|
||
If AttributeConstructor IsNot Nothing Then | ||
Return If(AttributeConstructor.GetUseSiteInfo().DiagnosticInfo, | ||
ErrorFactory.ErrorInfo(ERRID.ERR_UnsupportedType1, String.Empty)) |
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.
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.
Same response as for C#
Related to #70338.