-
Notifications
You must be signed in to change notification settings - Fork 229
Allow components in global namespace #10086
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
Changes from 11 commits
8a05492
9de3c17
b225060
acf1208
a7713a7
e9f30fb
61ead07
d5eeae8
7f6c75d
cfb9176
ae4fc31
8586250
1836b11
0d0bf2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // <auto-generated/> | ||
| #pragma warning disable 1591 | ||
|
|
||
| #line default | ||
| using global::System; | ||
| using global::System.Collections.Generic; | ||
| using global::System.Linq; | ||
| using global::System.Threading.Tasks; | ||
| using global::Microsoft.AspNetCore.Components; | ||
| #line default | ||
| #line hidden | ||
| #nullable restore | ||
| public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase | ||
| #nullable disable | ||
| { | ||
| #pragma warning disable 219 | ||
| private void __RazorDirectiveTokenHelpers__() { | ||
| } | ||
| #pragma warning restore 219 | ||
| #pragma warning disable 0414 | ||
| private static object __o = null; | ||
| #pragma warning restore 0414 | ||
| #pragma warning disable 1998 | ||
| protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) | ||
| { | ||
| __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { | ||
| } | ||
| )); | ||
| #nullable restore | ||
| #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" | ||
| __o = typeof(global::Component1); | ||
|
|
||
| #line default | ||
| #line hidden | ||
| #nullable disable | ||
| __builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => { | ||
| } | ||
| )); | ||
| #nullable restore | ||
| #line 3 "x:\dir\subdir\Test\TestComponent.cshtml" | ||
| __o = typeof(global::Shared.Component2); | ||
|
|
||
| #line default | ||
| #line hidden | ||
| #nullable disable | ||
| } | ||
| #pragma warning restore 1998 | ||
| } | ||
|
|
||
| #pragma warning restore 1591 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Document - | ||
| NamespaceDeclaration - - | ||
| UsingDirective - (3:1,1 [20] ) - global::System | ||
| UsingDirective - (26:2,1 [40] ) - global::System.Collections.Generic | ||
| UsingDirective - (69:3,1 [25] ) - global::System.Linq | ||
| UsingDirective - (97:4,1 [36] ) - global::System.Threading.Tasks | ||
| UsingDirective - (136:5,1 [45] ) - global::Microsoft.AspNetCore.Components | ||
| ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - | ||
| DesignTimeDirective - | ||
| CSharpCode - | ||
| IntermediateToken - - CSharp - #pragma warning disable 0414 | ||
| CSharpCode - | ||
| IntermediateToken - - CSharp - private static object __o = null; | ||
| CSharpCode - | ||
| IntermediateToken - - CSharp - #pragma warning restore 0414 | ||
| MethodDeclaration - - protected override - void - BuildRenderTree | ||
| MarkupElement - (0:0,0 [18] x:\dir\subdir\Test\TestComponent.cshtml) - h1 | ||
| HtmlContent - (4:0,4 [9] x:\dir\subdir\Test\TestComponent.cshtml) | ||
| LazyIntermediateToken - (4:0,4 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Generated | ||
| HtmlContent - (18:0,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) | ||
| LazyIntermediateToken - (18:0,18 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n | ||
| Component - (20:1,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Component1 | ||
| HtmlContent - (34:1,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) | ||
| LazyIntermediateToken - (34:1,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n | ||
| Component - (36:2,0 [21] x:\dir\subdir\Test\TestComponent.cshtml) - Shared.Component2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // <auto-generated/> | ||
| #pragma warning disable 1591 | ||
|
|
||
| #line default | ||
| using global::System; | ||
| using global::System.Collections.Generic; | ||
| using global::System.Linq; | ||
| using global::System.Threading.Tasks; | ||
| using global::Microsoft.AspNetCore.Components; | ||
| #line default | ||
| #line hidden | ||
| #nullable restore | ||
| public partial class TestComponent : global::Microsoft.AspNetCore.Components.ComponentBase | ||
| #nullable disable | ||
| { | ||
| #pragma warning disable 1998 | ||
| protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) | ||
| { | ||
| __builder.AddMarkupContent(0, "<h1>Generated</h1>\r\n"); | ||
| __builder.OpenComponent<global::Component1>(1); | ||
| __builder.CloseComponent(); | ||
| __builder.AddMarkupContent(2, "\r\n"); | ||
| __builder.OpenComponent<global::Shared.Component2>(3); | ||
| __builder.CloseComponent(); | ||
| } | ||
| #pragma warning restore 1998 | ||
| } | ||
|
|
||
| #pragma warning restore 1591 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| Document - | ||
| NamespaceDeclaration - - | ||
| UsingDirective - (3:1,1 [22] ) - global::System | ||
| UsingDirective - (26:2,1 [42] ) - global::System.Collections.Generic | ||
| UsingDirective - (69:3,1 [27] ) - global::System.Linq | ||
| UsingDirective - (97:4,1 [38] ) - global::System.Threading.Tasks | ||
| UsingDirective - (136:5,1 [47] ) - global::Microsoft.AspNetCore.Components | ||
| ClassDeclaration - - public partial - TestComponent - global::Microsoft.AspNetCore.Components.ComponentBase - | ||
| MethodDeclaration - - protected override - void - BuildRenderTree | ||
| MarkupBlock - - <h1>Generated</h1>\n | ||
| Component - (20:1,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - Component1 | ||
| HtmlContent - (34:1,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) | ||
| LazyIntermediateToken - (34:1,14 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n | ||
| Component - (36:2,0 [21] x:\dir\subdir\Test\TestComponent.cshtml) - Shared.Component2 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -115,8 +115,10 @@ private static TagHelperDescriptor CreateNameMatchingDescriptor( | |||||||||||||||
|
|
||||||||||||||||
| if (fullyQualified) | ||||||||||||||||
| { | ||||||||||||||||
| var containingNamespace = type.ContainingNamespace.ToDisplayString(); | ||||||||||||||||
| var fullName = $"{containingNamespace}.{type.Name}"; | ||||||||||||||||
| var containingNamespace = type.ContainingNamespace.ToDisplayString(SymbolExtensions.FullNameTypeDisplayFormat); | ||||||||||||||||
| var fullName = string.IsNullOrEmpty(containingNamespace) | ||||||||||||||||
| ? type.Name | ||||||||||||||||
| : $"{containingNamespace}.{type.Name}"; | ||||||||||||||||
|
||||||||||||||||
| var containingNamespace = type.ContainingNamespace.ToDisplayString(SymbolExtensions.FullNameTypeDisplayFormat); | |
| var fullName = string.IsNullOrEmpty(containingNamespace) | |
| ? type.Name | |
| : $"{containingNamespace}.{type.Name}"; | |
| var fullName = type.ContainingNamespace.IsGlobalNamespace | |
| ? type.Name | |
| : $"{type.ContainingNamespace.ToDisplayString(SymbolExtensions.FullNameTypeDisplayFormat)}.{type.Name}"; |
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.
Also, is it possible to have a component in a nested type? If so, will this handle that correctly?
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.
Also, is it possible to have a component in a nested type? If so, will this handle that correctly?
I don't think it's possible. (You've already asked me this previously in #9689 (comment) :D)
In any case, the previous code did "{namespace}.{typeName}" and I've just changed it to omit the "{namespace}." prefix when needed, so nothing should change at this front, right?
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.
_type.ContainingNamespace.ToDisplayString()would be"<global namespace>"; withSymbolExtensions.FullNameTypeDisplayFormatwe get an empty string instead (this format was already used in other places, just not everywhere)