You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Unrecognized reflection pattern warning IL2006: The parameter 'attributeType' of method 'System.Attribute System.Diagnostics.Tracing.EventSource::GetCustomAttributeHelper(System.Reflection.MemberInfo,System.Type,System.Diagnostics.Tracing.EventManifestOptions)' with dynamically accessed member kinds 'None' is passed into the parameter 'type' of method 'System.Object System.Activator::CreateInstance(System.Type)' which requires dynamically accessed member kinds `DefaultConstructor`. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'DefaultConstructor'.
I'd suggest
Add location information (at least assembly name)
Drop return types from the method signatures
Don't use parameter name but parameter index
Split the text to be easier to understand
a first warning for missing attribute
a second warning for incomplete MemberKinds
An example of the proposed change
(foo.dll) warning IL2006: The parameter '#1' in method 'System.Diagnostics.Tracing.EventSource::GetCustomAttributeHelper(System.Reflection.MemberInfo,System.Type,System.Diagnostics.Tracing.EventManifestOptions)' is missing 'DynamicallyAccessedMembersAttribute'. Consider adding it with 'DefaultConstructor' value.
Part of this should be to avoid printing out potentially long list of enum values. The DynamicallyAccessedMemberType is a flags enum, the warning message may potentially need to include representation of multiple such flags which would make it hard to read.
@marek-safar I don't understand why this is desirable:
Don't use parameter name but parameter index
I think that this will be rather confusing to users:
It's unclear if the numbering starts with 0 or 1
Parameter names are considered part of the public API surface (several languages can refer to them by name even in the callsite, not just the callee body)
The code will fallback to index when it can't determine the parameter name (never ran into that case though)
Reacted by Michal Strehovský and Alexander Köplinger
I'm not sure this is confusing. To me syntax #N means it starts with 1 or does #0 make sense to you like a number?
Parameter names are considered part of the public API
I don't think parameter names as part of the public API surface matter here, the error handling can happen anywhere, for private stuff, compiler-generated methods (maybe not for this code but in general).
The code will fallback to index when it can't determine the parameter name
Not sure we need this inconsistency. It could be just me but I look at the parameters by index so if the error message tells me it's #3 I go to 3rd parameter. When it tells me it's parameter position I need to read all parameters and find if there one with such name.
Not a big deal in general just not sure we need this complexity
Activity
vitek-karas commentedon Jul 8, 2020
Part of this should be to avoid printing out potentially long list of enum values. The
DynamicallyAccessedMemberTypeis a flags enum, the warning message may potentially need to include representation of multiple such flags which would make it hard to read.See #1315 (comment) for more details.
vitek-karas commentedon Jul 8, 2020
@marek-safar I don't understand why this is desirable:
I think that this will be rather confusing to users:
marek-safar commentedon Jul 8, 2020
I'm not sure this is confusing. To me syntax
#Nmeans it starts with 1 or does#0make sense to you like a number?I don't think parameter names as part of the public API surface matter here, the error handling can happen anywhere, for private stuff, compiler-generated methods (maybe not for this code but in general).
Not sure we need this inconsistency. It could be just me but I look at the parameters by index so if the error message tells me it's #3 I go to 3rd parameter. When it tells me it's parameter
positionI need to read all parameters and find if there one with such name.Not a big deal in general just not sure we need this complexity