Add regression test for 609

This commit is contained in:
Ryan Nowak 2018-05-22 11:53:09 -07:00
parent 3af9f4abd9
commit e801707706
8 changed files with 283 additions and 0 deletions

View File

@ -368,6 +368,43 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void Regression_609()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using System;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class User : BlazorComponent
{
public string Name { get; set; }
public Action<string> NameChanged { get; set; }
public bool IsActive { get; set; }
public Action<bool> IsActiveChanged { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<User bind-Name=""@UserName"" bind-IsActive=""@UserIsActive"" />
@functions {
public string UserName { get; set; }
public bool UserIsActive { get; set; }
}
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact] // https://github.com/aspnet/Blazor/issues/772
public void Regression_772()
{

View File

@ -618,6 +618,43 @@ namespace Test
CompileToAssembly(generated);
}
[Fact]
public void Regression_609()
{
// Arrange
AdditionalSyntaxTrees.Add(Parse(@"
using System;
using Microsoft.AspNetCore.Blazor.Components;
namespace Test
{
public class User : BlazorComponent
{
public string Name { get; set; }
public Action<string> NameChanged { get; set; }
public bool IsActive { get; set; }
public Action<bool> IsActiveChanged { get; set; }
}
}
"));
// Act
var generated = CompileToCSharp(@"
@addTagHelper *, TestAssembly
<User bind-Name=""@UserName"" bind-IsActive=""@UserIsActive"" />
@functions {
public string UserName { get; set; }
public bool UserIsActive { get; set; }
}
");
// Assert
AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
CompileToAssembly(generated);
}
[Fact] // https://github.com/aspnet/Blazor/issues/772
public void Regression_772()
{

View File

@ -0,0 +1,59 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((System.Action)(() => {
global::System.Object __typeHelper = "*, TestAssembly";
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static System.Object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
__o = Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
UserName
#line default
#line hidden
);
__o = Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => UserName = __value, UserName);
__o = Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
UserIsActive
#line default
#line hidden
);
__o = Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => UserIsActive = __value, UserIsActive);
builder.AddAttribute(-1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => {
}
));
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
public string UserName { get; set; }
public bool UserIsActive { get; set; }
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,47 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [12] ) - System
UsingDirective - (18:2,1 [32] ) - System.Collections.Generic
UsingDirective - (53:3,1 [17] ) - System.Linq
UsingDirective - (73:4,1 [28] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [33] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [44] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
DesignTimeDirective -
DirectiveToken - (14:0,14 [32] ) - "*, Microsoft.AspNetCore.Blazor"
DirectiveToken - (14:0,14 [9] ) - "*, Test"
DirectiveToken - (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml) - *, TestAssembly
CSharpCode -
IntermediateToken - - CSharp - #pragma warning disable 0414
CSharpCode -
IntermediateToken - - CSharp - private static System.Object __o = null;
CSharpCode -
IntermediateToken - - CSharp - #pragma warning restore 0414
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
HtmlContent - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (29:0,29 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
ComponentExtensionNode - (31:1,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - User - Test.User
ComponentAttributeExtensionNode - (48:1,17 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Name -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (49:1,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserName
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (48:1,17 [9] x:\dir\subdir\Test\TestComponent.cshtml) - NameChanged -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => UserName = __value, UserName)
ComponentAttributeExtensionNode - (74:1,43 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActive -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (75:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserIsActive
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (74:1,43 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActiveChanged -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => UserIsActive = __value, UserIsActive)
HtmlContent - (91:1,60 [4] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (91:1,60 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n
HtmlContent - (196:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (196:6,1 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
CSharpCode - (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string UserName { get; set; }\n public bool UserIsActive { get; set; }\n

View File

@ -0,0 +1,26 @@
Source Location: (14:0,14 [15] x:\dir\subdir\Test\TestComponent.cshtml)
|*, TestAssembly|
Generated Location: (559:16,38 [15] )
|*, TestAssembly|
Source Location: (49:1,18 [8] x:\dir\subdir\Test\TestComponent.cshtml)
|UserName|
Generated Location: (1135:30,18 [8] )
|UserName|
Source Location: (75:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml)
|UserIsActive|
Generated Location: (1495:38,44 [12] )
|UserIsActive|
Source Location: (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml)
|
public string UserName { get; set; }
public bool UserIsActive { get; set; }
|
Generated Location: (1951:50,12 [88] )
|
public string UserName { get; set; }
public bool UserIsActive { get; set; }
|

View File

@ -0,0 +1,35 @@
// <auto-generated/>
#pragma warning disable 1591
namespace Test
{
#line hidden
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Blazor;
using Microsoft.AspNetCore.Blazor.Components;
public class TestComponent : Microsoft.AspNetCore.Blazor.Components.BlazorComponent
{
#pragma warning disable 1998
protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder)
{
base.BuildRenderTree(builder);
builder.OpenComponent<Test.User>(0);
builder.AddAttribute(1, "Name", Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(UserName));
builder.AddAttribute(2, "NameChanged", Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => UserName = __value, UserName));
builder.AddAttribute(3, "IsActive", Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(UserIsActive));
builder.AddAttribute(4, "IsActiveChanged", Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => UserIsActive = __value, UserIsActive));
builder.CloseComponent();
}
#pragma warning restore 1998
#line 4 "x:\dir\subdir\Test\TestComponent.cshtml"
public string UserName { get; set; }
public bool UserIsActive { get; set; }
#line default
#line hidden
}
}
#pragma warning restore 1591

View File

@ -0,0 +1,31 @@
Document -
NamespaceDeclaration - - Test
UsingDirective - (3:1,1 [14] ) - System
UsingDirective - (18:2,1 [34] ) - System.Collections.Generic
UsingDirective - (53:3,1 [19] ) - System.Linq
UsingDirective - (73:4,1 [30] ) - System.Threading.Tasks
UsingDirective - (104:5,1 [35] ) - Microsoft.AspNetCore.Blazor
UsingDirective - (140:6,1 [46] ) - Microsoft.AspNetCore.Blazor.Components
ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Blazor.Components.BlazorComponent -
MethodDeclaration - - protected override - void - BuildRenderTree
CSharpCode -
IntermediateToken - - CSharp - base.BuildRenderTree(builder);
ComponentExtensionNode - (31:1,0 [60] x:\dir\subdir\Test\TestComponent.cshtml) - User - Test.User
ComponentAttributeExtensionNode - (48:1,17 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Name -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (49:1,18 [8] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserName
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (48:1,17 [9] x:\dir\subdir\Test\TestComponent.cshtml) - NameChanged -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => UserName = __value, UserName)
ComponentAttributeExtensionNode - (74:1,43 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActive -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.GetValue(
IntermediateToken - (75:1,44 [12] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - UserIsActive
IntermediateToken - - CSharp - )
ComponentAttributeExtensionNode - (74:1,43 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IsActiveChanged -
CSharpExpression -
IntermediateToken - - CSharp - Microsoft.AspNetCore.Blazor.Components.BindMethods.SetValueHandler(__value => UserIsActive = __value, UserIsActive)
CSharpCode - (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml)
IntermediateToken - (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public string UserName { get; set; }\n public bool UserIsActive { get; set; }\n

View File

@ -0,0 +1,11 @@
Source Location: (107:3,12 [88] x:\dir\subdir\Test\TestComponent.cshtml)
|
public string UserName { get; set; }
public bool UserIsActive { get; set; }
|
Generated Location: (1380:26,12 [88] )
|
public string UserName { get; set; }
public bool UserIsActive { get; set; }
|