Skip to content
This repository was archived by the owner on Sep 26, 2024. It is now read-only.

Conversation

@javiercn
Copy link
Member

@javiercn javiercn commented Feb 3, 2022

@javiercn javiercn requested a review from a team as a code owner February 3, 2022 17:49
pb.SetPropertyName(property.Name);
pb.IsEditorRequired = property.GetAttributes().Any(a => a.AttributeClass.ToDisplayString() == "Microsoft.AspNetCore.Components.EditorRequiredAttribute");

pb.SetGloballyQualifiedTypeName(property.Type.ToDisplayString(GloballyQualifiedFullNameTypeDisplayFormat));
Copy link
Member Author

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.

candidate = candidate.Left as QualifiedNameSyntax;
}
return false;
}
Copy link
Member Author

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);
Copy link
Member Author

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.

@javiercn javiercn merged commit 080bb02 into main Feb 4, 2022
@javiercn javiercn deleted the javiercn/fix-global-on-partial-type branch February 4, 2022 09:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect global:: for generic types

4 participants