Rename "Fixed" to "IsFixed"
This commit is contained in:
parent
7530ad9a26
commit
f0638877fa
|
|
@ -42,11 +42,11 @@ namespace Microsoft.AspNetCore.Blazor.Components
|
||||||
/// change notifications. Set this flag only if you will not change
|
/// change notifications. Set this flag only if you will not change
|
||||||
/// <see cref="Value"/> during the component's lifetime.
|
/// <see cref="Value"/> during the component's lifetime.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Parameter] private bool Fixed { get; set; }
|
[Parameter] private bool IsFixed { get; set; }
|
||||||
|
|
||||||
object ICascadingValueComponent.CurrentValue => Value;
|
object ICascadingValueComponent.CurrentValue => Value;
|
||||||
|
|
||||||
bool ICascadingValueComponent.CurrentValueIsFixed => Fixed;
|
bool ICascadingValueComponent.CurrentValueIsFixed => IsFixed;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Init(RenderHandle renderHandle)
|
public void Init(RenderHandle renderHandle)
|
||||||
|
|
@ -63,11 +63,11 @@ namespace Microsoft.AspNetCore.Blazor.Components
|
||||||
|
|
||||||
var hasSuppliedValue = false;
|
var hasSuppliedValue = false;
|
||||||
var previousValue = Value;
|
var previousValue = Value;
|
||||||
var previousFixed = Fixed;
|
var previousFixed = IsFixed;
|
||||||
Value = default;
|
Value = default;
|
||||||
ChildContent = null;
|
ChildContent = null;
|
||||||
Name = null;
|
Name = null;
|
||||||
Fixed = false;
|
IsFixed = false;
|
||||||
|
|
||||||
foreach (var parameter in parameters)
|
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.");
|
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
|
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;
|
_hasSetParametersPreviously = true;
|
||||||
|
|
@ -145,11 +145,11 @@ namespace Microsoft.AspNetCore.Blazor.Components
|
||||||
void ICascadingValueComponent.Subscribe(ComponentState subscriber)
|
void ICascadingValueComponent.Subscribe(ComponentState subscriber)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (Fixed)
|
if (IsFixed)
|
||||||
{
|
{
|
||||||
// Should not be possible. User code cannot trigger this.
|
// Should not be possible. User code cannot trigger this.
|
||||||
// Checking only to catch possible future framework bugs.
|
// 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
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
|
||||||
{
|
{
|
||||||
builder.OpenComponent<CascadingValue<string>>(0);
|
builder.OpenComponent<CascadingValue<string>>(0);
|
||||||
builder.AddAttribute(1, "Value", providedValue);
|
builder.AddAttribute(1, "Value", providedValue);
|
||||||
builder.AddAttribute(2, "Fixed", true);
|
builder.AddAttribute(2, "IsFixed", true);
|
||||||
builder.AddAttribute(3, RenderTreeBuilder.ChildContent, new RenderFragment(childBuilder =>
|
builder.AddAttribute(3, RenderTreeBuilder.ChildContent, new RenderFragment(childBuilder =>
|
||||||
{
|
{
|
||||||
if (shouldIncludeChild)
|
if (shouldIncludeChild)
|
||||||
|
|
@ -306,7 +306,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
|
||||||
var component = new TestComponent(builder =>
|
var component = new TestComponent(builder =>
|
||||||
{
|
{
|
||||||
builder.OpenComponent<CascadingValue<object>>(0);
|
builder.OpenComponent<CascadingValue<object>>(0);
|
||||||
builder.AddAttribute(1, "Fixed", isFixed);
|
builder.AddAttribute(1, "IsFixed", isFixed);
|
||||||
builder.AddAttribute(2, "Value", new object());
|
builder.AddAttribute(2, "Value", new object());
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
});
|
});
|
||||||
|
|
@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
isFixed = true;
|
isFixed = true;
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => component.TriggerRender());
|
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]
|
[Fact]
|
||||||
|
|
@ -330,7 +330,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
|
||||||
builder.OpenComponent<CascadingValue<object>>(0);
|
builder.OpenComponent<CascadingValue<object>>(0);
|
||||||
if (isFixed) // Showing also that "unset" is treated as "false"
|
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.AddAttribute(2, "Value", new object());
|
||||||
builder.CloseComponent();
|
builder.CloseComponent();
|
||||||
|
|
@ -341,7 +341,7 @@ namespace Microsoft.AspNetCore.Blazor.Test
|
||||||
// Act/Assert
|
// Act/Assert
|
||||||
isFixed = false;
|
isFixed = false;
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => component.TriggerRender());
|
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)
|
private static T FindComponent<T>(CapturedBatch batch, out int componentId)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
Each of the CascadingValue components here is configured differently for the test.
|
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 Value=counterState>
|
||||||
<CascadingValue Name="TestFlag1" Value="currentFlagValue1">
|
<CascadingValue Name="TestFlag1" Value="currentFlagValue1">
|
||||||
<CascadingValue Name="TestFlag2" Value="currentFlagValue2">
|
<CascadingValue Name="TestFlag2" Value="currentFlagValue2">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue