Rename "Fixed" to "IsFixed"

This commit is contained in:
Steve Sanderson 2018-10-18 09:43:11 +01:00
parent 7530ad9a26
commit f0638877fa
3 changed files with 16 additions and 16 deletions

View File

@ -42,11 +42,11 @@ namespace Microsoft.AspNetCore.Blazor.Components
/// change notifications. Set this flag only if you will not change
/// <see cref="Value"/> during the component's lifetime.
/// </summary>
[Parameter] private bool Fixed { get; set; }
[Parameter] private bool IsFixed { get; set; }
object ICascadingValueComponent.CurrentValue => Value;
bool ICascadingValueComponent.CurrentValueIsFixed => Fixed;
bool ICascadingValueComponent.CurrentValueIsFixed => IsFixed;
/// <inheritdoc />
public void Init(RenderHandle renderHandle)
@ -63,11 +63,11 @@ namespace Microsoft.AspNetCore.Blazor.Components
var hasSuppliedValue = false;
var previousValue = Value;
var previousFixed = Fixed;
var previousFixed = IsFixed;
Value = default;
ChildContent = null;
Name = null;
Fixed = false;
IsFixed = false;
foreach (var parameter in parameters)
{
@ -88,9 +88,9 @@ namespace Microsoft.AspNetCore.Blazor.Components
throw new ArgumentException($"The parameter '{nameof(Name)}' for component '{nameof(CascadingValue<T>)}' does not allow null or empty values.");
}
}
else if (parameter.Name.Equals(nameof(Fixed), StringComparison.OrdinalIgnoreCase))
else if (parameter.Name.Equals(nameof(IsFixed), StringComparison.OrdinalIgnoreCase))
{
Fixed = (bool)parameter.Value;
IsFixed = (bool)parameter.Value;
}
else
{
@ -98,9 +98,9 @@ namespace Microsoft.AspNetCore.Blazor.Components
}
}
if (_hasSetParametersPreviously && Fixed != previousFixed)
if (_hasSetParametersPreviously && IsFixed != previousFixed)
{
throw new InvalidOperationException($"The value of {nameof(Fixed)} cannot be changed dynamically.");
throw new InvalidOperationException($"The value of {nameof(IsFixed)} cannot be changed dynamically.");
}
_hasSetParametersPreviously = true;
@ -145,11 +145,11 @@ namespace Microsoft.AspNetCore.Blazor.Components
void ICascadingValueComponent.Subscribe(ComponentState subscriber)
{
#if DEBUG
if (Fixed)
if (IsFixed)
{
// Should not be possible. User code cannot trigger this.
// Checking only to catch possible future framework bugs.
throw new InvalidOperationException($"Cannot subscribe to a {typeof(CascadingValue<>).Name} when {nameof(Fixed)} is true.");
throw new InvalidOperationException($"Cannot subscribe to a {typeof(CascadingValue<>).Name} when {nameof(IsFixed)} is true.");
}
#endif

View File

@ -248,7 +248,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
{
builder.OpenComponent<CascadingValue<string>>(0);
builder.AddAttribute(1, "Value", providedValue);
builder.AddAttribute(2, "Fixed", true);
builder.AddAttribute(2, "IsFixed", true);
builder.AddAttribute(3, RenderTreeBuilder.ChildContent, new RenderFragment(childBuilder =>
{
if (shouldIncludeChild)
@ -306,7 +306,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
var component = new TestComponent(builder =>
{
builder.OpenComponent<CascadingValue<object>>(0);
builder.AddAttribute(1, "Fixed", isFixed);
builder.AddAttribute(1, "IsFixed", isFixed);
builder.AddAttribute(2, "Value", new object());
builder.CloseComponent();
});
@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
// Act/Assert
isFixed = true;
var ex = Assert.Throws<InvalidOperationException>(() => component.TriggerRender());
Assert.Equal("The value of Fixed cannot be changed dynamically.", ex.Message);
Assert.Equal("The value of IsFixed cannot be changed dynamically.", ex.Message);
}
[Fact]
@ -330,7 +330,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
builder.OpenComponent<CascadingValue<object>>(0);
if (isFixed) // Showing also that "unset" is treated as "false"
{
builder.AddAttribute(1, "Fixed", true);
builder.AddAttribute(1, "IsFixed", true);
}
builder.AddAttribute(2, "Value", new object());
builder.CloseComponent();
@ -341,7 +341,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
// Act/Assert
isFixed = false;
var ex = Assert.Throws<InvalidOperationException>(() => component.TriggerRender());
Assert.Equal("The value of Fixed cannot be changed dynamically.", ex.Message);
Assert.Equal("The value of IsFixed cannot be changed dynamically.", ex.Message);
}
private static T FindComponent<T>(CapturedBatch batch, out int componentId)

View File

@ -6,7 +6,7 @@
Each of the CascadingValue components here is configured differently for the test.
*@
<CascadingValue Value=this Fixed=true>
<CascadingValue Value=this IsFixed=true>
<CascadingValue Value=counterState>
<CascadingValue Name="TestFlag1" Value="currentFlagValue1">
<CascadingValue Name="TestFlag2" Value="currentFlagValue2">