parent
8757c7da16
commit
35daeda2bf
|
|
@ -874,7 +874,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
|
|||
// errors will be equivalent
|
||||
var captureTypeName = node.IsComponentCapture
|
||||
? node.ComponentCaptureTypeName
|
||||
: ComponentsApi.ElementRef.FullTypeName;
|
||||
: ComponentsApi.ElementReference.FullTypeName;
|
||||
WriteCSharpCode(context, new CSharpCodeIntermediateNode
|
||||
{
|
||||
Source = node.Source,
|
||||
|
|
|
|||
|
|
@ -792,7 +792,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
|
|||
//
|
||||
// builder.AddComponentReferenceCapture(2, (__value) = { _field = (MyComponent)__value; });
|
||||
// OR
|
||||
// builder.AddElementReferenceCapture(2, (__value) = { _field = (ElementRef)__value; });
|
||||
// builder.AddElementReferenceCapture(2, (__value) = { _field = (ElementReference)__value; });
|
||||
var codeWriter = context.CodeWriter;
|
||||
|
||||
var methodName = node.IsComponentCapture
|
||||
|
|
|
|||
|
|
@ -123,9 +123,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
|
|||
public static readonly string FullTypeName = "Microsoft.AspNetCore.Components.EventHandlerAttribute";
|
||||
}
|
||||
|
||||
public static class ElementRef
|
||||
public static class ElementReference
|
||||
{
|
||||
public static readonly string FullTypeName = "Microsoft.AspNetCore.Components.ElementRef";
|
||||
public static readonly string FullTypeName = "Microsoft.AspNetCore.Components.ElementReference";
|
||||
}
|
||||
|
||||
public static class EventCallback
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
|
||||
public string ComponentCaptureTypeName { get; set; }
|
||||
|
||||
public string FieldTypeName => IsComponentCapture ? ComponentCaptureTypeName : "global::" + ComponentsApi.ElementRef.FullTypeName;
|
||||
public string FieldTypeName => IsComponentCapture ? ComponentCaptureTypeName : "global::" + ComponentsApi.ElementReference.FullTypeName;
|
||||
|
||||
public string TypeName => $"global::System.Action<{FieldTypeName}>";
|
||||
|
||||
|
|
|
|||
|
|
@ -3742,7 +3742,7 @@ namespace Test
|
|||
var generated = CompileToCSharp(@"
|
||||
<elem @ref=""myElem"" @ref:suppressField>Hello</elem>
|
||||
@code {
|
||||
ElementRef myElem;
|
||||
ElementReference myElem;
|
||||
void DoStuff() { GC.KeepAlive(myElem); }
|
||||
}");
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
|
|||
// Assert
|
||||
var field = component.GetType().GetField("myDiv", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
Assert.NotNull(field);
|
||||
Assert.Same(typeof(ElementRef), field.FieldType);
|
||||
Assert.Same(typeof(ElementReference), field.FieldType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Test
|
|||
{
|
||||
#pragma warning disable 0414
|
||||
#pragma warning disable 0169
|
||||
private global::Microsoft.AspNetCore.Components.ElementRef myElem;
|
||||
private global::Microsoft.AspNetCore.Components.ElementReference myElem;
|
||||
#pragma warning restore 0169
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 219
|
||||
|
|
@ -27,7 +27,7 @@ namespace Test
|
|||
{
|
||||
#nullable restore
|
||||
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
myElem = default(Microsoft.AspNetCore.Components.ElementRef);
|
||||
myElem = default(Microsoft.AspNetCore.Components.ElementReference);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Document -
|
|||
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
|
||||
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
|
||||
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - myElem
|
||||
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementReference - myElem
|
||||
DesignTimeDirective -
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Source Location: (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|myElem|
|
||||
Generated Location: (1108:29,37 [6] )
|
||||
Generated Location: (1114:29,37 [6] )
|
||||
|myElem|
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Test
|
|||
{
|
||||
#pragma warning disable 0414
|
||||
#pragma warning disable 0169
|
||||
private global::Microsoft.AspNetCore.Components.ElementRef _element;
|
||||
private global::Microsoft.AspNetCore.Components.ElementReference _element;
|
||||
#pragma warning restore 0169
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 219
|
||||
|
|
@ -36,7 +36,7 @@ namespace Test
|
|||
;
|
||||
#nullable restore
|
||||
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
_element = default(Microsoft.AspNetCore.Components.ElementRef);
|
||||
_element = default(Microsoft.AspNetCore.Components.ElementReference);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Document -
|
|||
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (104:5,1 [37] ) - Microsoft.AspNetCore.Components
|
||||
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
|
||||
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - _element
|
||||
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementReference - _element
|
||||
DesignTimeDirective -
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
Source Location: (37:0,37 [3] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|Min|
|
||||
Generated Location: (1130:30,37 [3] )
|
||||
Generated Location: (1136:30,37 [3] )
|
||||
|Min|
|
||||
|
||||
Source Location: (49:0,49 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|_element|
|
||||
Generated Location: (1319:38,49 [8] )
|
||||
Generated Location: (1325:38,49 [8] )
|
||||
|_element|
|
||||
|
||||
Source Location: (72:2,7 [56] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|
|
||||
[Parameter] public int Min { get; set; }
|
||||
|
|
||||
Generated Location: (1560:47,7 [56] )
|
||||
Generated Location: (1572:47,7 [56] )
|
||||
|
|
||||
[Parameter] public int Min { get; set; }
|
||||
|
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Test
|
|||
{
|
||||
#nullable restore
|
||||
#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
myElem = default(Microsoft.AspNetCore.Components.ElementRef);
|
||||
myElem = default(Microsoft.AspNetCore.Components.ElementReference);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
|
@ -32,7 +32,7 @@ namespace Test
|
|||
#nullable restore
|
||||
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
|
||||
ElementRef myElem;
|
||||
ElementReference myElem;
|
||||
void DoStuff() { GC.KeepAlive(myElem); }
|
||||
|
||||
#line default
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@ Document -
|
|||
ReferenceCapture - (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml) - myElem
|
||||
HtmlContent - (51:0,51 [2] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (51:0,51 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
|
||||
CSharpCode - (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n ElementRef myElem;\n void DoStuff() { GC.KeepAlive(myElem); }\n
|
||||
CSharpCode - (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n ElementReference myElem;\n void DoStuff() { GC.KeepAlive(myElem); }\n
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|
|||
Generated Location: (855:24,12 [6] )
|
||||
|myElem|
|
||||
|
||||
Source Location: (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
Source Location: (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|
|
||||
ElementRef myElem;
|
||||
ElementReference myElem;
|
||||
void DoStuff() { GC.KeepAlive(myElem); }
|
||||
|
|
||||
Generated Location: (1094:33,7 [72] )
|
||||
Generated Location: (1100:33,7 [78] )
|
||||
|
|
||||
ElementRef myElem;
|
||||
ElementReference myElem;
|
||||
void DoStuff() { GC.KeepAlive(myElem); }
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Test
|
|||
{
|
||||
#pragma warning disable 0414
|
||||
#pragma warning disable 0169
|
||||
private global::Microsoft.AspNetCore.Components.ElementRef myElem;
|
||||
private global::Microsoft.AspNetCore.Components.ElementReference myElem;
|
||||
#pragma warning restore 0169
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Document -
|
|||
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
|
||||
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
|
||||
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - myElem
|
||||
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementReference - myElem
|
||||
MethodDeclaration - - protected override - void - BuildRenderTree
|
||||
MarkupElement - (0:0,0 [80] x:\dir\subdir\Test\TestComponent.cshtml) - elem
|
||||
HtmlContent - (68:0,68 [5] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Source Location: (37:0,37 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|myElem|
|
||||
Generated Location: (1083:26,37 [6] )
|
||||
Generated Location: (1089:26,37 [6] )
|
||||
|myElem|
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Test
|
|||
{
|
||||
#pragma warning disable 0414
|
||||
#pragma warning disable 0169
|
||||
private global::Microsoft.AspNetCore.Components.ElementRef _element;
|
||||
private global::Microsoft.AspNetCore.Components.ElementReference _element;
|
||||
#pragma warning restore 0169
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Document -
|
|||
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (104:5,1 [39] ) - Microsoft.AspNetCore.Components
|
||||
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
|
||||
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementRef - _element
|
||||
FieldDeclaration - - private - global::Microsoft.AspNetCore.Components.ElementReference - _element
|
||||
MethodDeclaration - - protected override - void - BuildRenderTree
|
||||
MarkupElement - (0:0,0 [61] x:\dir\subdir\Test\TestComponent.cshtml) - input
|
||||
HtmlAttribute - - type=" - "
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
Source Location: (49:0,49 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|_element|
|
||||
Generated Location: (1255:34,49 [8] )
|
||||
Generated Location: (1261:34,49 [8] )
|
||||
|_element|
|
||||
|
||||
Source Location: (72:2,7 [56] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|
|
||||
[Parameter] public int Min { get; set; }
|
||||
|
|
||||
Generated Location: (1520:46,7 [56] )
|
||||
Generated Location: (1526:46,7 [56] )
|
||||
|
|
||||
[Parameter] public int Min { get; set; }
|
||||
|
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Test
|
|||
#nullable restore
|
||||
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
|
||||
|
||||
ElementRef myElem;
|
||||
ElementReference myElem;
|
||||
void DoStuff() { GC.KeepAlive(myElem); }
|
||||
|
||||
#line default
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ Document -
|
|||
HtmlContent - (39:0,39 [5] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (39:0,39 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello
|
||||
ReferenceCapture - (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml) - myElem
|
||||
CSharpCode - (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n ElementRef myElem;\n void DoStuff() { GC.KeepAlive(myElem); }\n
|
||||
CSharpCode - (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
IntermediateToken - (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n ElementReference myElem;\n void DoStuff() { GC.KeepAlive(myElem); }\n
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ Source Location: (12:0,12 [6] x:\dir\subdir\Test\TestComponent.cshtml)
|
|||
Generated Location: (698:19,12 [6] )
|
||||
|myElem|
|
||||
|
||||
Source Location: (60:1,7 [72] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
Source Location: (60:1,7 [78] x:\dir\subdir\Test\TestComponent.cshtml)
|
||||
|
|
||||
ElementRef myElem;
|
||||
ElementReference myElem;
|
||||
void DoStuff() { GC.KeepAlive(myElem); }
|
||||
|
|
||||
Generated Location: (1006:32,7 [72] )
|
||||
Generated Location: (1006:32,7 [78] )
|
||||
|
|
||||
ElementRef myElem;
|
||||
ElementReference myElem;
|
||||
void DoStuff() { GC.KeepAlive(myElem); }
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ namespace Microsoft.CodeAnalysis.Razor
|
|||
return;
|
||||
}
|
||||
|
||||
var elementRef = compilation.GetTypeByMetadataName(ComponentsApi.ElementRef.FullTypeName);
|
||||
if (elementRef == null)
|
||||
var elementReference = compilation.GetTypeByMetadataName(ComponentsApi.ElementReference.FullTypeName);
|
||||
if (elementReference == null)
|
||||
{
|
||||
// If we can't find ElementRef, then just bail. We won't be able to compile the
|
||||
// generated code anyway.
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Components.RenderTree
|
|||
[System.Runtime.InteropServices.FieldOffsetAttribute(16)]
|
||||
public readonly string ElementName;
|
||||
[System.Runtime.InteropServices.FieldOffsetAttribute(24)]
|
||||
public readonly System.Action<Microsoft.AspNetCore.Components.ElementRef> ElementReferenceCaptureAction;
|
||||
public readonly System.Action<Microsoft.AspNetCore.Components.ElementReference> ElementReferenceCaptureAction;
|
||||
[System.Runtime.InteropServices.FieldOffsetAttribute(16)]
|
||||
public readonly string ElementReferenceCaptureId;
|
||||
[System.Runtime.InteropServices.FieldOffsetAttribute(8)]
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Components
|
|||
protected void OnUnhandledException(System.UnhandledExceptionEventArgs e) { }
|
||||
}
|
||||
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
||||
public readonly partial struct ElementRef
|
||||
public readonly partial struct ElementReference
|
||||
{
|
||||
private readonly object _dummy;
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
|
|
@ -719,7 +719,7 @@ namespace Microsoft.AspNetCore.Components.RenderTree
|
|||
public void AddContent(int sequence, object textContent) { }
|
||||
public void AddContent(int sequence, string textContent) { }
|
||||
public void AddContent<T>(int sequence, Microsoft.AspNetCore.Components.RenderFragment<T> fragment, T value) { }
|
||||
public void AddElementReferenceCapture(int sequence, System.Action<Microsoft.AspNetCore.Components.ElementRef> elementReferenceCaptureAction) { }
|
||||
public void AddElementReferenceCapture(int sequence, System.Action<Microsoft.AspNetCore.Components.ElementReference> elementReferenceCaptureAction) { }
|
||||
public void AddMarkupContent(int sequence, string markupContent) { }
|
||||
public void AddMultipleAttributes(int sequence, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>> attributes) { }
|
||||
public void Clear() { }
|
||||
|
|
|
|||
Loading…
Reference in New Issue