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

Values in CompilerVisibleProperty containing #s don't transfer to source generators #56656

Closed
MichaelSimons opened this issue Sep 23, 2021 · 2 comments

Comments

@MichaelSimons
Copy link
Member

MichaelSimons commented Sep 23, 2021

Razor's source generator adds the RootNamespace MSBuild property to the list of CompilerVisibleProperty. It uses this to calculate namespace for the generated types. In the GeneratedMSBuildEditorConfig.editorconfig, the value that gets written to is build_property.RootNamespace = C#_blazorwasm. The value that the source generator reads it is C which results in a bunch of code generation errors.

For some file metadata read by the source generator, our SDK currently does some custom encoding to avoid this issue. I'd like to avoid doing this for this metadata because the issue isn't unique to Razor and other SG authors are also likely to get in to trouble because of it.


Original issue description:

Steps to Reproduce

  1. Using .NET sdk 6.0.100-rc.2.21471.7
  2. mkdir C#_blazorwasm
  3. cd C#_blazorwasm
  4. dotnet new blazorwasm
  5. dotnet build

Actual Results
Project fails to build

Microsoft (R) Build Engine version 17.0.0-preview-21378-03+d592862ed for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
d:\test\blazor\C#_blazorwasm\Pages\Index.razor(7,1): warning RZ10012: Found markup element with unexpected name 'SurveyPrompt'. If this is intended to be a component, add a @using directive for its namespace. [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
D:\test\blazor\C#_blazorwasm\Program.cs(2,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]

Build FAILED.

d:\test\blazor\C#_blazorwasm\Pages\Index.razor(7,1): warning RZ10012: Found markup element with unexpected name 'SurveyPrompt'. If this is intended to be a component, add a @using directive for its namespace. [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
D:\test\blazor\C#_blazorwasm\Program.cs(2,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(9,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
d:\test\blazor\C#_blazorwasm\_Imports.razor(10,7): error CS0246: The type or namespace name 'C__blazorwasm' could not be found (are you missing a using directive or an assembly reference?) [D:\test\blazor\C#_blazorwasm\C#_blazorwasm.csproj]
    1 Warning(s)
    17 Error(s)

Excepted Results
Project builds cleanly with no errors.

@pranavkm pranavkm transferred this issue from dotnet/aspnetcore Sep 23, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 23, 2021
@pranavkm pranavkm changed the title blazorwasm project fails to build when project name contains a '#' Values in CompilerVisibleProperty containing #s don't transfer to source generators Sep 23, 2021
@pranavkm
Copy link
Contributor

Possibly related issue: #44596

@jinujoseph jinujoseph added Area-IDE Bug and removed Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 29, 2021
@sharwell
Copy link
Member

Duplicate of #51692

@sharwell sharwell marked this as a duplicate of #51692 Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants