Skip to content

Conversation

@jtschuster
Copy link
Member

@jtschuster jtschuster commented Dec 15, 2021

Diagnostic messages would occasionally use the Cecil FullName property which uses '/' as a delimiter for nested classes. The standard is to use '.' instead. This fix uses GetDisplayName() instead to accomplish this.

Fixes #2441

Customer Impact

Improves warning messages by better formatting nested type names.

Testing

Manually verified improved warning messages.

Risk

Very low - only affects warning messages.

Cecil `FullName` properties use '/' as delimiters for nested classes,
but the standard is to use '.'. GetDisplayName extension is used instead
to accomplish this.
@jtschuster jtschuster changed the base branch from main to release/6.0.2xx December 15, 2021 20:19
if (Origin?.Provider is MethodDefinition method)
sb.Append (method.GetDisplayName ());
else if (Origin?.Provider is TypeDefinition type)
else if (Origin?.Provider is MemberReference type)
Copy link
Member

Choose a reason for hiding this comment

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

While I think this is in general correct, it feels dangerous. If there can be an instance of IMemberDefinition which is not MemberReference we would now throw NotSupportedException. Which would be a regression. Quickly looking through Cecil, this should not be the case, but I don't know for sure.
Would be safer to keep the IMemberDefinition case as a fallback.

if (Origin?.Provider is MethodDefinition method)
sb.Append (method.GetDisplayName ());
else if (Origin?.Provider is TypeDefinition type)
else if (Origin?.Provider is MemberReference type)
Copy link
Contributor

@tlakollo tlakollo Dec 15, 2021

Choose a reason for hiding this comment

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

nit: probably change the name from 'type', a memberReference could be several things

@jtschuster jtschuster force-pushed the RemoveCecilFullNameDiags branch 2 times, most recently from fcc8c0c to 86cf8f2 Compare December 15, 2021 22:28
@jtschuster jtschuster force-pushed the RemoveCecilFullNameDiags branch from 86cf8f2 to 93fb2a7 Compare December 15, 2021 22:31
@jtschuster jtschuster merged commit 0ee8afd into dotnet:release/6.0.2xx Dec 15, 2021
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…NameDiags

Remove cecil FullName property from diagnostic messages

Commit migrated from dotnet/linker@0ee8afd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetDisplayName() and FullName use different notation for nested classes

3 participants