-
Notifications
You must be signed in to change notification settings - Fork 643
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
Add a polyfill to enable newer compiler features #10315
base: dev
Are you sure you want to change the base?
Conversation
New versions of C# offer many features that improve quality of life: nullable annotations, record types, init and required properties, etc. These can be enabled in projects targeting older framework versions by adding the right attributes and types to the compilation. PolySharp is a source generator which automatically does this. For each project, it will generate all of the types/attributes which are missing. In the case of an InternalsVisibleTo reference, it is smart enough to only define types in the second assembly that are not being consumed from the first assembly (avoiding duplicate type definitions).
3185208
to
d6b5c7e
Compare
@@ -19,6 +19,44 @@ public void ShouldOnlyHaveInterfacesAndEnums() | |||
// included in the assembly by newer language versions | |||
"Microsoft.CodeAnalysis.EmbeddedAttribute", | |||
"System.Runtime.CompilerServices.RefSafetyRulesAttribute", | |||
// generated polyfills from PolySharp | |||
"System.Runtime.CompilerServices.NullableAttribute", |
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.
Hmm I wonder if we can filter out internal
types for this test. This test appears to be a "public contract changes should be acknowledged by this test".
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.
we could easily check only types where type.IsVisible
is true
true if the current Type is a public type or a public nested type such that all the enclosing types are public; otherwise, false.
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.
Sounds good.
New versions of C# offer many features that improve quality of life: nullable annotations, record types, init and required properties, etc. These can be enabled in projects targeting older framework versions by adding the right attributes and types to the compilation.
PolySharp is a source generator which automatically does this. For each project, it will generate all of the types/attributes which are missing. In the case of an InternalsVisibleTo reference, it is smart enough to only define types in the second assembly that are not being consumed from the first assembly (avoiding duplicate type definitions).