-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[8.0.100-preview.3.23178.7] Incremental Roslyn Source Generator ToDisplayString() method returns different value in 7.0.20X and later #67632
Comments
@jcouv Could you help check this issue and confirm whether it is a blocker for .NET 8.0 Preview3 validation? Please help move to the right area if it was assigned incorrect. Thanks. |
This is by design. Getting the display string for a parameter always returns its name now. |
@CyrusNajmabadi is this documented as a breaking change? .NET breaking changes are published on https://learn.microsoft.com/en-us/dotnet/core/compatibility/8.0 and template for breaking changes is here |
I don't believe so. This api is only for display purposes, so the expectation is that it might change over time if we feel the display is better. |
We are the .NET AppCompat team and we have a representative set of apps in our lab. Generally, an issue that we find in-house could potentially impact a bigger customer base in the real world. As a result, we ask teams if the change can be made in a less breaking way and secondly, we ask all teams to follow the breaking change process since it is important to communicate to customers about the breaking change. cc @marklio for additional inputs. |
This is not a breaking change. This is a display string (similar to how .ToString would work). That's a core part of it's name and contract here in its doc comment
You'd use it to put something in a display that a user might look at. The expectation is that it could potentially change and adapt as we decide what looks good for users. |
Note: the code in questino does this: methodSymbol.Parameters.Select(x => x.ToDisplayString()) We have never stated in docs (and have stated plainly to customers elsewhere like in our communities) that ToDisplayString'ing random symbols is not a guarantee of parseable code. It is not a part of any contract (implied, or explicit) that this would ever work, and we def have and will continue to change display strings such that this may not work. Users are strongly advised to produce trees/code using supported mechanisms (SyntaxFactory/SyntaxGenerator) if they want to ensure parseable/compilable code. |
This all makes sense to me. I do think there is an opportunity to be more explicit in the docs about not using the output of such "display" APIs to generate code, and that such output is subject to change to most appropriately reflect a useful display string. I think there's an opportunity to do even more here, like analyzers that would warn about the use of such APIs in source generators. The compat lab has a good track record of forecasting customer disruption. I would expect that other customers will encounter this issue. |
Assigned to @jjonescz to add a note in breaking changes doc as FYI. We may need to discuss with Jared and Cyrus to confirm. |
Describe the bug
App is using source generator to create additional C# code, but code generated is different in 7.0.20X and later (Include 8.0 preview), so code doesn't compile, build fails.
Application Name: PixiEditorDotNetCore
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-8.0.100-preview.3.23178.7
App Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1784818/
Or Github link: https://github.com/flabbet/PixiEditor
Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.100-preview.3.23178.7: Fail
2). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.100-preview.2.23153.6: Fail
3). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.100-preview.1.23115.2: Fail
4). Windows 10 21H2 AMD64 + dotnet-sdk-7.0.104: Pass
5). Windows 10 21H2 AMD64 + dotnet-sdk-7.0.105: Pass
6). Windows 10 21H2 AMD64 + dotnet-sdk-7.0.202: Fail
Repro steps:
Build project with 7.0.20X SDK or later.
Expected Result:
build successfully.
Actual Result:
build failed with errors.
Repro Steps to produce from sample project: Attached a sample project:
TestCodeGeneration.zip
build with SDK 7.0.202 or later
build with SDK 7.0.104
For Sample APP, when we compare the source code generated from app, we noticed the difference between 7.0.10X and 7.0.20X
.NET 7.0.202 or later
.NET 7.0.104
Findings
It looks like ToDisplayString() method, returns different values in the code below.
@dotnet-actwx-bot @dotnet/compat
The text was updated successfully, but these errors were encountered: