Skip to content
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

[wasm] WBT: Use project ids that are safe for use as identifiers #89945

Merged
merged 2 commits into from
Aug 3, 2023

Conversation

radical
Copy link
Member

@radical radical commented Aug 3, 2023

For every test project, a random id is used which is
Path.GetRandomFileName(). In some cases this id gets used in a
generated C/C# source file, and that can cause failures.

For example the following fails with:

blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,48): error CS1001: Identifier expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]
blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,48): error CS1002: ; expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]
blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,51): error CS1031: Type expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]

because the id, blz_checkfingerprinting_Release_zqkzgkui.ref, was used
as a namespace (line 3).

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using blz_checkfingerprinting_Release_zqkzgkui.ref;

Fix up the generated random ids to make them safer. The code is taken
from WasmAppBuilder/ManagedToNativeGenerator.cs.

Fixes #86533 .

For every test project, a random id is used which is
`Path.GetRandomFileName()`. In some cases this `id` gets used in a
generated C/C# source file, and that can cause failures.

For example the following fails with:

```
blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,48): error CS1001: Identifier expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]
blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,48): error CS1002: ; expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]
blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,51): error CS1031: Type expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]
```

because the id, `blz_checkfingerprinting_Release_zqkzgkui.ref`, was used
as a namespace (line 3).

```
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using blz_checkfingerprinting_Release_zqkzgkui.ref;
```

Fix up the generated random ids to make them safer. The code is taken
from `WasmAppBuilder/ManagedToNativeGenerator.cs`.

Fixes dotnet#86533 .
@radical radical added the arch-wasm WebAssembly architecture label Aug 3, 2023
@ghost
Copy link

ghost commented Aug 3, 2023

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

For every test project, a random id is used which is
Path.GetRandomFileName(). In some cases this id gets used in a
generated C/C# source file, and that can cause failures.

For example the following fails with:

blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,48): error CS1001: Identifier expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]
blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,48): error CS1002: ; expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]
blz_checkfingerprinting_Release_zqkzgkui.ref/Program.cs(3,51): error CS1031: Type expected [/root/helix/work/workitem/e/wbt/blz_checkfingerprinting_Release_zqkzgkui.ref/blz_checkfingerprinting_Release_zqkzgkui.ref.csproj]

because the id, blz_checkfingerprinting_Release_zqkzgkui.ref, was used
as a namespace (line 3).

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using blz_checkfingerprinting_Release_zqkzgkui.ref;

Fix up the generated random ids to make them safer. The code is taken
from WasmAppBuilder/ManagedToNativeGenerator.cs.

Fixes #86533 .

Author: radical
Assignees: -
Labels:

arch-wasm

Milestone: -

@radical radical merged commit 2699015 into dotnet:main Aug 3, 2023
30 checks passed
@radical radical deleted the fix-ids-in-wbt branch August 3, 2023 22:50
@ghost ghost locked as resolved and limited conversation to collaborators Sep 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Build-mono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[wasm] Random blazor build failures in WBT - error CS1001: Identifier expected
2 participants