-
Notifications
You must be signed in to change notification settings - Fork 32
Avoid globally qualifying user defined types #69
Conversation
| pb.SetPropertyName(property.Name); | ||
| pb.IsEditorRequired = property.GetAttributes().Any(a => a.AttributeClass.ToDisplayString() == "Microsoft.AspNetCore.Components.EditorRequiredAttribute"); | ||
|
|
||
| pb.SetGloballyQualifiedTypeName(property.Type.ToDisplayString(GloballyQualifiedFullNameTypeDisplayFormat)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key is here, where we capture the globally qualified type name for the type. This comes from the symbol, and we re-use it later on.
src/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentNodeWriter.cs
Outdated
Show resolved
Hide resolved
| candidate = candidate.Left as QualifiedNameSyntax; | ||
| } | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rewriter needs to account for the fact that the types might already be globally qualified
| // the type name. | ||
| if (!globallyQualifiedTypeName.StartsWith("global::", StringComparison.Ordinal)) | ||
| { | ||
| attribute.Annotations.Add(ComponentMetadata.Component.ExplicitTypeNameKey, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this metadata to signal that we replaced something like TItem with potential user input, like MyType (which we can't qualify) to avoid prepending global:: incorrectly.
Fixes dotnet/aspnetcore#39950