Repository navigation
Change check NotInheritedAttribute - #4668
Conversation
Change check InheritedAttribute for classes BaseB and DerivedB to check NotInheritedAttribute
rpetrusha
left a comment
There was a problem hiding this comment.
Thank you , @AlexandrTsvetkov, for contributing to the dotnet/docs repo and for correcting what I suspect was a copy-and-paste error in the code example. There's also a Visual Basic example in dotnet/docs/samples/snippets/visualbasic/VS_Snippets_CLR_System/System.AttributeUsageAttribute.Inherited/vb. Would you mind fixing that as well? Or if you prefer, we can make the changes for you.
| typeB.GetCustomAttributes(typeof(InheritedAttribute), true).Length > 0); | ||
| Console.WriteLine("DerivedB has NotInherited attribute: {0}", | ||
| typeB.GetCustomAttributes(typeof(NotInheritedAttribute), true).Length > 0); | ||
| MethodInfo memberB = typeB.GetMethod("MethodB"); |
There was a problem hiding this comment.
Would be nice to use nameof operator here: MethodInfo memberB = typeB.GetMethod(nameof(DerivedB.MethodB));
In line 40, I suggest the same change to MethodInfo memberA = typeA.GetMethod("MethodA");
|
Thank you for your suggestion @rpetrusha . Unfortunately, I don't use Visual Basic and it will be much more better, if you fix it by yourself. |
Found and updated while added the VB version
Also, switch to using interpolated strings.
BillWagner
left a comment
There was a problem hiding this comment.
Thanks for fixing this @AlexandrTsvetkov We do appreciate the work.
@rpetrusha I made the VB updates, and also switched the C# code to use interpolated strings.
|
Thanks again for opening this issue and correcting the C# code, @AlexandrTsvetkov, and thanks for correcting the VB code, @BillWagner. We'll merge your PR now. The changes should appear live on docs.microsoft.com in the next day or two. |
Change check
InheritedAttributefor classesBaseBandDerivedBto checkNotInheritedAttribute