-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add GetDeclaringType to PropertyDefinition and EventDefinition.
#111646
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
Changes from 4 commits
fbc42b2
e1cfa01
1a5769c
4779643
b908468
f421e9c
2013a59
d362dad
8fd3b53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,5 +32,41 @@ public void ValidateTypeDefinitionIsNestedWindowsProjection() | |
| Assert.Equal(typeDef.Attributes.IsNested(), typeDef.IsNested); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ValidateDeclaringType() | ||
| { | ||
| var reader = MetadataReaderTests.GetMetadataReader(Misc.Members); | ||
|
|
||
| foreach (var typeDefHandle in reader.TypeDefinitions) | ||
| { | ||
| var typeDef = reader.GetTypeDefinition(typeDefHandle); | ||
| foreach (var nestedTypeHandle in typeDef.GetNestedTypes()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a sanity check here to make sure that these foreach statement actually loop through at least one? Like: Assert.True(typeDef.GetNestedTypes().Length > 0);There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test assembly actually dosen't have any nested types. I tried to add some but after recompiling it this assert failed. Your suggested assert wouldn't currently work, because not all types have all kinds of members each. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added asserts that |
||
| { | ||
| var nestedType = reader.GetTypeDefinition(nestedTypeHandle); | ||
| Assert.Equal(typeDefHandle, nestedType.GetDeclaringType()); | ||
| } | ||
| foreach (var fieldHandle in typeDef.GetFields()) | ||
| { | ||
| var field = reader.GetFieldDefinition(fieldHandle); | ||
| Assert.Equal(typeDefHandle, field.GetDeclaringType()); | ||
| } | ||
| foreach (var methodHandle in typeDef.GetMethods()) | ||
| { | ||
| var method = reader.GetMethodDefinition(methodHandle); | ||
| Assert.Equal(typeDefHandle, method.GetDeclaringType()); | ||
| } | ||
| foreach (var eventHandle in typeDef.GetEvents()) | ||
| { | ||
| var eventDef = reader.GetEventDefinition(eventHandle); | ||
| Assert.Equal(typeDefHandle, eventDef.GetDeclaringType()); | ||
| } | ||
| foreach (var propertyHandle in typeDef.GetProperties()) | ||
| { | ||
| var property = reader.GetPropertyDefinition(propertyHandle); | ||
| Assert.Equal(typeDefHandle, property.GetDeclaringType()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.