Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

GetDisplayName uses 'ref Type' instead of 'Type&' - #2461

Closed
jtschuster wants to merge 1 commit into
dotnet:mainfrom
jtschuster:fixRefParamFormat
Closed

jtschuster wants to merge 1 commit into
dotnet:mainfrom
jtschuster:fixRefParamFormat

Conversation

@jtschuster

Copy link
Copy Markdown
Member

Modifies the behavior of GetDisplayName in the Linker to use the 'ref Type' format instead of the 'Type&' that is default in Cecil. Fixes #2406

@tlakollo tlakollo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, but we will need to follow up with this change in case merged to see nothing breaks in the SDK and runtime. Maybe someone suppresses something and now it will start failing

@marek-safar

Copy link
Copy Markdown
Contributor

What is the motivation for this change?

@jtschuster

Copy link
Copy Markdown
Member Author

What is the motivation for this change?

@marek-safar The original issue was filed in response to this discussion. I think in general we're trying to have our notation match C# warning notation.

@MichalStrehovsky

Copy link
Copy Markdown
Member

What is the motivation for this change?

@marek-safar The original issue was filed in response to this discussion. I think in general we're trying to have our notation match C# warning notation.

I'm not a big fan of doing this. & is universally correct because it matches what the reflection stack would write for byref parameters.

This change makes the warning confusing for a C# developer if they actually had in, out, or ref readonly instead of ref in the signature. To be not confusing, we would also have to consider the difference from in and out. But do note that in and ref readonly is pretty recent, C# might add more keywords in the future, and we'll need to play catch up or keep confusing users.

VB and F# devs will have no clue what ref/in/out mean in either case.

@jtschuster

Copy link
Copy Markdown
Member Author

What is the motivation for this change?

@marek-safar The original issue was filed in response to this discussion. I think in general we're trying to have our notation match C# warning notation.

I'm not a big fan of doing this. & is universally correct because it matches what the reflection stack would write for byref parameters.

This change makes the warning confusing for a C# developer if they actually had in, out, or ref readonly instead of ref in the signature. To be not confusing, we would also have to consider the difference from in and out. But do note that in and ref readonly is pretty recent, C# might add more keywords in the future, and we'll need to play catch up or keep confusing users.

VB and F# devs will have no clue what ref/in/out mean in either case.

That's a really good point, if the linker deals with IL that could be from any .NET language, should we ever be using C# notation in linker diagnostics? And if we should use IL notation, do we want C# analyzers producing slightly different diagnostics that are C# specific and more understandable? I've been getting the impression we want the linker and the analyzers to produce identical diagnostics and use C#/Roslyn notation, but maybe we should rethink that.
@tlakollo @vitek-karas @sbomer @agocke thoughts?

@marek-safar

Copy link
Copy Markdown
Contributor

I'm not a big fan of doing this. & is universally correct because it matches what the reflection stack would write for byref parameters.

I agree with Michal, ILLinker operates at IL/metadata level and the closest match to that is reflection. I think all error messages that come from illinker (not analyzers) should use reflection notation (or something very close to it).

We could explore the option of customizing the output based on the compiler used to produce the assembly but I'm really not sure it's worth it and it still has shortcomings because there are many different compilers (e.g. iron python).

Another option would be the explicit --diagnostic csharp option but that for me would make sense if we enhanced C# compiler to produce more metadadata for illinker to easily map any metadata to C# syntax.

@sbomer

sbomer commented Jan 3, 2022

Copy link
Copy Markdown
Member

@jtschuster thanks for kicking off a good discussion with this change. I made #2406 a tracking issue for changing the linker warnings to use reflection notation.

@jtschuster jtschuster closed this Jan 6, 2022
@jtschuster
jtschuster deleted the fixRefParamFormat branch February 17, 2022 17:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use reflection signature format in linker warnings

5 participants