diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs
index f7b56c84b6..d56d87209e 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentBindLoweringPass.cs
@@ -290,13 +290,22 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
return new[] { node };
}
- // Look for a matching format node. If we find one then we need to pass the format into the
+ // Look for a format. If we find one then we need to pass the format into the
// two nodes we generate.
IntermediateToken format = null;
if (bindEntry.BindFormatNode != null)
{
format = GetAttributeContent(bindEntry.BindFormatNode);
}
+ else if (node.TagHelper?.GetFormat() != null)
+ {
+ // We may have a default format if one is associated with the field type.
+ format = new IntermediateToken()
+ {
+ Kind = TokenKind.CSharp,
+ Content = "\"" + node.TagHelper.GetFormat() + "\"",
+ };
+ }
if (TryGetFormatNode(
parent,
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
index 69874ce9c5..8365be7a63 100644
--- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs
@@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
internal override bool UseTwoPhaseCompilation => true;
protected ComponentCodeGenerationTestBase()
- : base(generateBaselines: null)
+ : base(generateBaselines: false)
{
}
@@ -1162,6 +1162,64 @@ namespace Test
CompileToAssembly(generated);
}
+ [Fact]
+ public void BuiltIn_BindToInputWithDefaultFormat()
+ {
+ // Arrange
+ AdditionalSyntaxTrees.Add(Parse(@"
+using System;
+using Microsoft.AspNetCore.Components;
+
+namespace Test
+{
+ [BindInputElement(""custom"", null, ""value"", ""onchange"", isInvariantCulture: false, format: ""MM/dd"")]
+ public static class BindAttributes
+ {
+ }
+}"));
+
+ // Act
+ var generated = CompileToCSharp(@"
+
+@code {
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+}");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
+ [Fact]
+ public void BuiltIn_BindToInputWithDefaultFormat_Override()
+ {
+ // Arrange
+ AdditionalSyntaxTrees.Add(Parse(@"
+using System;
+using Microsoft.AspNetCore.Components;
+
+namespace Test
+{
+ [BindInputElement(""custom"", null, ""value"", ""onchange"", isInvariantCulture: false, format: ""MM/dd"")]
+ public static class BindAttributes
+ {
+ }
+}"));
+
+ // Act
+ var generated = CompileToCSharp(@"
+
+@code {
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+}");
+
+ // Assert
+ AssertDocumentNodeMatchesBaseline(generated.CodeDocument);
+ AssertCSharpDocumentMatchesBaseline(generated.CodeDocument);
+ CompileToAssembly(generated);
+ }
+
#endregion
#region Child Content
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.codegen.cs
new file mode 100644
index 0000000000..8690bcc8a0
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.codegen.cs
@@ -0,0 +1,45 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #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.Components.RenderTree.RenderTreeBuilder builder)
+ {
+ __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+ CurrentDate
+
+#line default
+#line hidden
+#nullable disable
+ , "MM/dd");
+ __o = Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, CurrentDate, "MM/dd");
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt
new file mode 100644
index 0000000000..1085bec8ec
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt
@@ -0,0 +1,34 @@
+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 [37] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ 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
+ MarkupElement - (0:0,0 [44] x:\dir\subdir\Test\TestComponent.cshtml) - input
+ HtmlAttribute - - type=" - "
+ HtmlAttributeValue - (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) -
+ IntermediateToken - (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - custom
+ HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - "
+ CSharpExpressionAttributeValue - -
+ IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue(
+ IntermediateToken - (29:0,29 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate
+ IntermediateToken - - CSharp - ,
+ IntermediateToken - - CSharp - "MM/dd"
+ IntermediateToken - - CSharp - )
+ HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - "
+ CSharpExpressionAttributeValue - -
+ IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, CurrentDate, "MM/dd")
+ HtmlContent - (44:0,44 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (44:0,44 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (53:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (53:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.mappings.txt
new file mode 100644
index 0000000000..861fb34670
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.mappings.txt
@@ -0,0 +1,14 @@
+Source Location: (29:0,29 [11] x:\dir\subdir\Test\TestComponent.cshtml)
+|CurrentDate|
+Generated Location: (945:25,29 [11] )
+|CurrentDate|
+
+Source Location: (53:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+|
+Generated Location: (1308:36,7 [77] )
+|
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.codegen.cs
new file mode 100644
index 0000000000..18d2c291e1
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.codegen.cs
@@ -0,0 +1,45 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 219
+ private void __RazorDirectiveTokenHelpers__() {
+ }
+ #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.Components.RenderTree.RenderTreeBuilder builder)
+ {
+ __o = Microsoft.AspNetCore.Components.BindMethods.GetValue(
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+ CurrentDate
+
+#line default
+#line hidden
+#nullable disable
+ , "MM/dd/yyyy");
+ __o = Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, CurrentDate, "MM/dd/yyyy");
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt
new file mode 100644
index 0000000000..5c29e17fe7
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt
@@ -0,0 +1,34 @@
+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 [37] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ DesignTimeDirective -
+ 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
+ MarkupElement - (0:0,0 [69] x:\dir\subdir\Test\TestComponent.cshtml) - input
+ HtmlAttribute - - type=" - "
+ HtmlAttributeValue - (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) -
+ IntermediateToken - (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - custom
+ HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - "
+ CSharpExpressionAttributeValue - -
+ IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue(
+ IntermediateToken - (29:0,29 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate
+ IntermediateToken - - CSharp - ,
+ IntermediateToken - - CSharp - "MM/dd/yyyy"
+ IntermediateToken - - CSharp - )
+ HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - "
+ CSharpExpressionAttributeValue - -
+ IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, CurrentDate, "MM/dd/yyyy")
+ HtmlContent - (69:0,69 [2] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (69:0,69 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n
+ CSharpCode - (78:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (78:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.mappings.txt
new file mode 100644
index 0000000000..356abede57
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.mappings.txt
@@ -0,0 +1,14 @@
+Source Location: (29:0,29 [11] x:\dir\subdir\Test\TestComponent.cshtml)
+|CurrentDate|
+Generated Location: (945:25,29 [11] )
+|CurrentDate|
+
+Source Location: (78:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+|
+Generated Location: (1318:36,7 [77] )
+|
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.codegen.cs
new file mode 100644
index 0000000000..723601591b
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.codegen.cs
@@ -0,0 +1,42 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
+ {
+ builder.OpenElement(0, "input");
+ builder.AddAttribute(1, "type", "custom");
+ builder.AddAttribute(2, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+ CurrentDate
+
+#line default
+#line hidden
+#nullable disable
+ , "MM/dd"));
+ builder.AddAttribute(3, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, CurrentDate, "MM/dd"));
+ builder.SetUpdatesAttributeName("value");
+ builder.CloseElement();
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt
new file mode 100644
index 0000000000..199522aa35
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.ir.txt
@@ -0,0 +1,25 @@
+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 [39] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupElement - (0:0,0 [44] x:\dir\subdir\Test\TestComponent.cshtml) - input
+ HtmlAttribute - - type=" - "
+ HtmlAttributeValue - (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) -
+ IntermediateToken - (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - custom
+ HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - "
+ CSharpExpressionAttributeValue - -
+ IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue(
+ IntermediateToken - (29:0,29 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate
+ IntermediateToken - - CSharp - ,
+ IntermediateToken - - CSharp - "MM/dd"
+ IntermediateToken - - CSharp - )
+ HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - "
+ CSharpExpressionAttributeValue - -
+ IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, CurrentDate, "MM/dd")
+ CSharpCode - (53:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (53:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.mappings.txt
new file mode 100644
index 0000000000..1d58848f84
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat/TestComponent.mappings.txt
@@ -0,0 +1,9 @@
+Source Location: (53:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+|
+Generated Location: (1293:33,7 [77] )
+|
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+|
+
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.codegen.cs
new file mode 100644
index 0000000000..a1f0888016
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.codegen.cs
@@ -0,0 +1,42 @@
+//
+#pragma warning disable 1591
+namespace Test
+{
+ #line hidden
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Threading.Tasks;
+ using Microsoft.AspNetCore.Components;
+ public class TestComponent : Microsoft.AspNetCore.Components.ComponentBase
+ {
+ #pragma warning disable 1998
+ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder)
+ {
+ builder.OpenElement(0, "input");
+ builder.AddAttribute(1, "type", "custom");
+ builder.AddAttribute(2, "value", Microsoft.AspNetCore.Components.BindMethods.GetValue(
+#nullable restore
+#line 1 "x:\dir\subdir\Test\TestComponent.cshtml"
+ CurrentDate
+
+#line default
+#line hidden
+#nullable disable
+ , "MM/dd/yyyy"));
+ builder.AddAttribute(3, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, CurrentDate, "MM/dd/yyyy"));
+ builder.SetUpdatesAttributeName("value");
+ builder.CloseElement();
+ }
+ #pragma warning restore 1998
+#nullable restore
+#line 2 "x:\dir\subdir\Test\TestComponent.cshtml"
+
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+
+#line default
+#line hidden
+#nullable disable
+ }
+}
+#pragma warning restore 1591
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt
new file mode 100644
index 0000000000..202cfe56df
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.ir.txt
@@ -0,0 +1,25 @@
+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 [39] ) - Microsoft.AspNetCore.Components
+ ClassDeclaration - - public - TestComponent - Microsoft.AspNetCore.Components.ComponentBase -
+ MethodDeclaration - - protected override - void - BuildRenderTree
+ MarkupElement - (0:0,0 [69] x:\dir\subdir\Test\TestComponent.cshtml) - input
+ HtmlAttribute - - type=" - "
+ HtmlAttributeValue - (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) -
+ IntermediateToken - (13:0,13 [6] x:\dir\subdir\Test\TestComponent.cshtml) - Html - custom
+ HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - value=" - "
+ CSharpExpressionAttributeValue - -
+ IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.BindMethods.GetValue(
+ IntermediateToken - (29:0,29 [11] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - CurrentDate
+ IntermediateToken - - CSharp - ,
+ IntermediateToken - - CSharp - "MM/dd/yyyy"
+ IntermediateToken - - CSharp - )
+ HtmlAttribute - (28:0,28 [12] x:\dir\subdir\Test\TestComponent.cshtml) - onchange=" - "
+ CSharpExpressionAttributeValue - -
+ IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentDate = __value, CurrentDate, "MM/dd/yyyy")
+ CSharpCode - (78:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml)
+ IntermediateToken - (78:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);\n
diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.mappings.txt
new file mode 100644
index 0000000000..dd10b89979
--- /dev/null
+++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/BuiltIn_BindToInputWithDefaultFormat_Override/TestComponent.mappings.txt
@@ -0,0 +1,9 @@
+Source Location: (78:1,7 [77] x:\dir\subdir\Test\TestComponent.cshtml)
+|
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+|
+Generated Location: (1303:33,7 [77] )
+|
+ public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
+|
+