-
-
Notifications
You must be signed in to change notification settings - Fork 9
Improve processing of custom attributes #173
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
Improve processing of custom attributes #173
Conversation
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (6)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
3d062bb
to
21d66b2
Compare
- Add new list of namespaces to exclude from metadata. - TypeReferenceExtensions.IsToInclude extension now uses that list along with the classes to exclude. - Add new class to test app with DoesNotReturn attribute. - Improve GetTestNFAppAssemblyDefinitionWithLoadHints. - Add new test for System.Diagnostics.CodeAnalysis attributes.
21d66b2
to
a16ea1e
Compare
Failing because of mismatch in nanoCLR. Expected. Merging. |
(cherry picked from commit 79db556)
Description
TypeReferenceExtensions.IsToInclude
extension now uses that list along with the classes to exclude.Motivation and Context
DoesNotReturn
attribute on an assembly referencing it would cause a type reference missing exception when running the app.First finding was that the type was excluded from the metadata (on purpose) by adding a
NFMDP_PE_ExcludeClassByName
entry in the project file. Which was correct, in principle, becauseDoesNotReturn
class (and friends) are only used by the compiler and have no part in the execution.All unit tests of mscorlib were all passing, despite some of the methods are decorate with the
DoesNotReturn
attribute, which seem odd at first.Inspecting the generated IL of
ArgumentNullException.Throw
which is decorated withDoesNotReturn
attribute:Shows that the compiler adds a custom attribute of this type
System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute
. ECMA-335 specs state that custom attributes are added to the metadata, which is being honoured by .NET nanoFramework metadata processor.Adding a unit test validating the absence of this attribute on an assembly using
DoesNotReturn
attribute, fails. Dump file also shows the attribute in the TypeRef table.Assembly minimization relies on
TypeReferenceExtensions.IsToInclude
which includes a hard coded list of the attributes to automatically exclude. This is the root cause of the type being added to the metadata. Because it was referenced by a custom attribute, despite not being used in any code, it was being added to the TypeRef table.It's not practical to keep manually adding exclusions to this list. Moreover, it's prone to errors such as in this situation because it was overlooked the need to update the list.
TypeReferenceExtensions.IsToInclude
was reworked to also check a list of know name spaces whose types are deemed to be automatically excluded from our metadata.System.Diagnostics.CodeAnalysis
is the first entry there as all types living there are only used by the compiler.How Has This Been Tested?
Screenshots
Types of changes
Checklist: