Open
Description
Description
The source generator emits non-user code methods without #line
directives. That's usually ok, since the code is not expected to be stepped into or compiler errors are not expected to occur in it. However, changing the declaration of a partial method stub annotated by JSImport attribute during EnC/Hot Reload might result in rude edits. Currently, these diagnostics are reported with locations pointing to the source-generated file.
Adding #line
directives that map the locations back to the originating declaration would improve the experience. The IDE would then show the errors in the source file where the user is actually making the changes.
Reproduction Steps
dotnet new blazorwasm -o testblazor01
cd testblazor01
- In
testblazor01.csproj
add the following:
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- In
Program.cs
, add the following at the end:
public static partial class Test
{
[System.Runtime.InteropServices.JavaScript.JSImport("test")]
public static partial void F(int a);
}
- Open the project in VS and start debugging (F10)
- Change the signature of Test method to:
public static partial void F(int a, int b);
- Open Hot Reload pane of Output window
Expected behavior
[Error] C:\Test\testblazor01\Program.cs (line 18): error ENC0044: Modifying method which contains the stackalloc operator requires restarting the application.
[Error] C:\Test\testblazor01\Program.cs (line 18): error ENC0020: Renaming field '__signature_F_583343223' requires restarting the application.
Actual behavior
[Error] Microsoft.Interop.JavaScript.JSImportGenerator\Microsoft.Interop.JavaScript.JSImportGenerator\JSImports.g.cs (line 12): error ENC0044: Modifying method which contains the stackalloc operator requires restarting the application.
[Error] Microsoft.Interop.JavaScript.JSImportGenerator\Microsoft.Interop.JavaScript.JSImportGenerator\JSImports.g.cs (line 26): error ENC0020: Renaming field '__signature_F_583343223' requires restarting the application.
Regression?
No
Known Workarounds
No response
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Type
Projects
Status
No status