-
Notifications
You must be signed in to change notification settings - Fork 199
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
Generator incorrectly prefixes relative namespaced types with global::
#8610
Comments
Please prioritize investigating this. This issue is blocking dotnet/aspnetcore from updating the SDK (it's been blocked on various issues for over 2 weeks) |
The issue only appears if the [Fact, WorkItem("https://github.com/dotnet/razor/issues/8610")]
public async Task SourceGenerator_RazorFiles_UsingAlias()
{
// Arrange
var project = CreateTestProject(new()
{
["Pages/Index.razor"] = """
@code {
public class MyModel { }
}
""",
["Shared/MyComponent.razor"] = """
@using MyAlias = Pages.Index.MyModel;
<MyComponent Data="@Data" />
@code {
[Parameter]
public MyAlias Data { get; set; }
}
""",
});
var compilation = await project.GetCompilationAsync();
var driver = await GetDriverAsync(project);
// Act
var result = RunGenerator(compilation!, ref driver);
// Assert
Assert.Empty(result.Diagnostics);
Assert.Equal(2, result.GeneratedSources.Length);
} |
OK. This regression has been introduced by #8212. Before, when creating tag helper descriptor for the component, the compilation contained declaration syntax trees of all components, i.e., while inspecting type of property This leaves the property with an error type which is just emitted as-is. The error has nothing to do with |
See dotnet/aspnetcore#47540
There is an alias
@using WeatherForecast = Pages.GridRendering.WeatherForecast
where thePages
namespace is relative to the containing namespace (I.e., not at the root)We're incorrectly code-genning
global::Pages.GridRendering.WeatherForecast
which is not valid; we should either leave it relative or add in the full namespace of the type.The text was updated successfully, but these errors were encountered: