Add culture parameter to element-bind tag helpers
\n\nCommit migrated from 7515e2ce49
This commit is contained in:
parent
66cb243807
commit
04d7e63b79
|
|
@ -129,6 +129,9 @@
|
||||||
<data name="BindTagHelper_Component_Documentation" xml:space="preserve">
|
<data name="BindTagHelper_Component_Documentation" xml:space="preserve">
|
||||||
<value>Binds the provided expression to the '{0}' property and a change event delegate to the '{1}' property of the component.</value>
|
<value>Binds the provided expression to the '{0}' property and a change event delegate to the '{1}' property of the component.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="BindTagHelper_Element_Culture_Documentation" xml:space="preserve">
|
||||||
|
<value>Specifies the culture to use for conversions.</value>
|
||||||
|
</data>
|
||||||
<data name="BindTagHelper_Element_Documentation" xml:space="preserve">
|
<data name="BindTagHelper_Element_Documentation" xml:space="preserve">
|
||||||
<value>Binds the provided expression to the '{0}' attribute and a change event delegate to the '{1}' attribute.</value>
|
<value>Binds the provided expression to the '{0}' attribute and a change event delegate to the '{1}' attribute.</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Razor.Language;
|
using Microsoft.AspNetCore.Razor.Language;
|
||||||
using Microsoft.AspNetCore.Razor.Language.Components;
|
using Microsoft.AspNetCore.Razor.Language.Components;
|
||||||
|
|
@ -177,6 +178,15 @@ namespace Microsoft.CodeAnalysis.Razor
|
||||||
|
|
||||||
parameter.SetPropertyName("Event");
|
parameter.SetPropertyName("Event");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
attribute.BindAttributeParameter(parameter =>
|
||||||
|
{
|
||||||
|
parameter.Name = "culture";
|
||||||
|
parameter.TypeName = typeof(CultureInfo).FullName;
|
||||||
|
parameter.Documentation = ComponentResources.BindTagHelper_Element_Culture_Documentation;
|
||||||
|
|
||||||
|
parameter.SetPropertyName("Culture");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// This is no longer supported. This is just here so we can add a diagnostic later on when this matches.
|
// This is no longer supported. This is just here so we can add a diagnostic later on when this matches.
|
||||||
|
|
@ -381,6 +391,15 @@ namespace Microsoft.CodeAnalysis.Razor
|
||||||
|
|
||||||
parameter.SetPropertyName(eventName);
|
parameter.SetPropertyName(eventName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
a.BindAttributeParameter(parameter =>
|
||||||
|
{
|
||||||
|
parameter.Name = "culture";
|
||||||
|
parameter.TypeName = typeof(CultureInfo).FullName;
|
||||||
|
parameter.Documentation = ComponentResources.BindTagHelper_Element_Culture_Documentation;
|
||||||
|
|
||||||
|
parameter.SetPropertyName("Culture");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// This is no longer supported. This is just here so we can add a diagnostic later on when this matches.
|
// This is no longer supported. This is just here so we can add a diagnostic later on when this matches.
|
||||||
|
|
|
||||||
|
|
@ -432,6 +432,28 @@ namespace Test
|
||||||
Assert.True(parameter.IsStringProperty);
|
Assert.True(parameter.IsStringProperty);
|
||||||
Assert.False(parameter.IsBooleanProperty);
|
Assert.False(parameter.IsBooleanProperty);
|
||||||
Assert.False(parameter.IsEnum);
|
Assert.False(parameter.IsEnum);
|
||||||
|
|
||||||
|
parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("culture"));
|
||||||
|
|
||||||
|
// Invariants
|
||||||
|
Assert.Empty(parameter.Diagnostics);
|
||||||
|
Assert.False(parameter.HasErrors);
|
||||||
|
Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind);
|
||||||
|
Assert.False(parameter.IsDefaultKind());
|
||||||
|
|
||||||
|
Assert.Equal(
|
||||||
|
"Specifies the culture to use for conversions.",
|
||||||
|
parameter.Documentation);
|
||||||
|
|
||||||
|
Assert.Equal("culture", parameter.Name);
|
||||||
|
Assert.Equal("Culture", parameter.GetPropertyName());
|
||||||
|
Assert.Equal(":culture", parameter.DisplayName);
|
||||||
|
|
||||||
|
// Defined from the property type
|
||||||
|
Assert.Equal("System.Globalization.CultureInfo", parameter.TypeName);
|
||||||
|
Assert.False(parameter.IsStringProperty);
|
||||||
|
Assert.False(parameter.IsBooleanProperty);
|
||||||
|
Assert.False(parameter.IsEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -847,8 +869,29 @@ namespace Test
|
||||||
Assert.True(parameter.IsStringProperty);
|
Assert.True(parameter.IsStringProperty);
|
||||||
Assert.False(parameter.IsBooleanProperty);
|
Assert.False(parameter.IsBooleanProperty);
|
||||||
Assert.False(parameter.IsEnum);
|
Assert.False(parameter.IsEnum);
|
||||||
}
|
|
||||||
|
|
||||||
|
parameter = Assert.Single(attribute.BoundAttributeParameters, a => a.Name.Equals("culture"));
|
||||||
|
|
||||||
|
// Invariants
|
||||||
|
Assert.Empty(parameter.Diagnostics);
|
||||||
|
Assert.False(parameter.HasErrors);
|
||||||
|
Assert.Equal(ComponentMetadata.Bind.TagHelperKind, parameter.Kind);
|
||||||
|
Assert.False(parameter.IsDefaultKind());
|
||||||
|
|
||||||
|
Assert.Equal(
|
||||||
|
"Specifies the culture to use for conversions.",
|
||||||
|
parameter.Documentation);
|
||||||
|
|
||||||
|
Assert.Equal("culture", parameter.Name);
|
||||||
|
Assert.Equal("Culture", parameter.GetPropertyName());
|
||||||
|
Assert.Equal(":culture", parameter.DisplayName);
|
||||||
|
|
||||||
|
// Defined from the property type
|
||||||
|
Assert.Equal("System.Globalization.CultureInfo", parameter.TypeName);
|
||||||
|
Assert.False(parameter.IsStringProperty);
|
||||||
|
Assert.False(parameter.IsBooleanProperty);
|
||||||
|
Assert.False(parameter.IsEnum);
|
||||||
|
}
|
||||||
|
|
||||||
private static TagHelperDescriptor[] GetBindTagHelpers(TagHelperDescriptorProviderContext context)
|
private static TagHelperDescriptor[] GetBindTagHelpers(TagHelperDescriptorProviderContext context)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue