Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

No description provided.

}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2006:UnrecognizedReflectionPattern",
Justification = "Unused fields don't make a difference for hashcode quality")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we're OK with the hascode value itself changing as a result of trimming, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think so. We can make this invariant if we keep all fields of attributes in linker, but I don't think we care so much.

Whoever cares about these hashcodes is probably already overriding this implementation (this returns the hashcode of the first non-null field and if that field also happens to be unused - that's a pretty bad hashcode).


[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2006:UnrecognizedReflectionPattern",
Justification = "Linker doesn't recongnize GetConstructors(BindingFlags.Public) but this is safe")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use "safe"... it resembles security, which this is not about (I know we use it a lot, but we should try to stay away from it)

}
}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2006:UnrecognizedReflectionPattern",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question on RequiresUnreferencedCode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linker intrinsically recognizes all these weird overloads. This was ported from @marek-safar's original prototype. I don't think we would add them based on API usage telemetry since nobody uses these APIs.

Yes, my preference would be to make these string,string overloads RequiresUnreferencedCode, delete the linker handling, and be done with it.

Having to mark these UnconditionalSuppressMessage is unfortunate because it puts us into a situation where forgetting to intrinsically recognize this API (e.g. once we build a Roslyn analyzer) will result in potentially broken apps.

With the other annotations in this pull request, if we forget to intrinsically recognize a rare overload, it will result in more warnings, not less warnings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could start with more aggressive mode and block less APIs based on previews feedback.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@MichalStrehovsky MichalStrehovsky merged commit 0f97c7a into dotnet:master Jun 9, 2020
@MichalStrehovsky MichalStrehovsky deleted the moreCoreLibAnnot branch June 9, 2020 07:30
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants