From 3e0c0fe176c543803f64538e8c8501d3648f27c1 Mon Sep 17 00:00:00 2001 From: shahryar saljoughi Date: Sat, 8 Mar 2025 00:18:04 +0330 Subject: [PATCH 1/2] pass ParameterView AS IS to base, unless base is ComponentBase. This ensures that when passing ParameterView to base classes like InputBase cascaded parameters are not lost. --- .../Blazor/BlazorSetParametersSourceGenerator.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorSetParametersSourceGenerator.cs b/src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorSetParametersSourceGenerator.cs index 74303402db..84be4a6e90 100644 --- a/src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorSetParametersSourceGenerator.cs +++ b/src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorSetParametersSourceGenerator.cs @@ -71,7 +71,6 @@ public override Task SetParametersAsync(ParameterView parameters) // source.AppendLine($" {bitProperty.PropertySymbol.Name}HasBeenSet = true;"); //} source.AppendLine($" {bitProperty.PropertySymbol.Name} = parameter.Value is null ? default! : ({bitProperty.PropertySymbol.Type.ToDisplayString()})parameter.Value;"); - source.AppendLine(" parametersDictionary.Remove(parameter.Key);"); source.AppendLine(" break;"); } @@ -84,7 +83,7 @@ public override Task SetParametersAsync(ParameterView parameters) } else { - source.AppendLine(" return base.SetParametersAsync(ParameterView.FromDictionary(parametersDictionary as IDictionary));"); + source.AppendLine(" return base.SetParametersAsync(parameters);"); } source.AppendLine(" }"); From 3dfb96a3a5abe280b25585398f67ca858d72e4ef Mon Sep 17 00:00:00 2001 From: shahryar saljoughi Date: Sat, 8 Mar 2025 11:42:45 +0330 Subject: [PATCH 2/2] Directly use ParameterView without conversion to Dictionary --- .../Blazor/BlazorSetParametersSourceGenerator.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorSetParametersSourceGenerator.cs b/src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorSetParametersSourceGenerator.cs index 84be4a6e90..60f414ab60 100644 --- a/src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorSetParametersSourceGenerator.cs +++ b/src/SourceGenerators/Bit.SourceGenerators/Blazor/BlazorSetParametersSourceGenerator.cs @@ -56,10 +56,9 @@ public override Task SetParametersAsync(ParameterView parameters) //{ // source.AppendLine($" {property.PropertySymbol.Name}HasBeenSet = false;"); //} - source.AppendLine(" var parametersDictionary = parameters.ToDictionary() as Dictionary;"); - source.AppendLine(" foreach (var parameter in parametersDictionary!)"); + source.AppendLine(" foreach (var parameter in parameters)"); source.AppendLine(" {"); - source.AppendLine(" switch (parameter.Key)"); + source.AppendLine(" switch (parameter.Name)"); source.AppendLine(" {"); // create cases for each property