From 36e764d07b4fa106b5e43db24d74134bd4cd1118 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Wed, 24 Jun 2026 13:52:31 +0300 Subject: [PATCH] Online demos: support C# 12+ syntax and preserve more trimmed types Two follow-up fixes for compiling demos in Edit Source / Playground: - CompilerService: raise the parse language version from C# 10 to Latest so demos using collection expressions and primary constructors compile (previously failed with CS8936). - linker.xml: preserve System.Math, DisplayAttribute and Radzen.Colors, which are referenced only by demo source compiled at runtime and were otherwise removed by trimming (Math.PI, [Display(Description=...)], @Colors.* respectively). Verified against a trimmed publish: demo compile failures drop from 20 to 5 out of 1052 (remaining 5 are a separate Razor type-inference codegen issue). --- RadzenBlazorDemos/Services/CompilerService.cs | 2 +- RadzenBlazorDemos/linker.xml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RadzenBlazorDemos/Services/CompilerService.cs b/RadzenBlazorDemos/Services/CompilerService.cs index f36d7108c..e28494bc3 100644 --- a/RadzenBlazorDemos/Services/CompilerService.cs +++ b/RadzenBlazorDemos/Services/CompilerService.cs @@ -196,7 +196,7 @@ namespace RadzenBlazorDemos .Replace("#nullable enable", "#nullable disable") .Replace("where TItem : , notnull", "where TItem : notnull"); - var syntaxTree = CSharpSyntaxTree.ParseText(generatedCode, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp10)); + var syntaxTree = CSharpSyntaxTree.ParseText(generatedCode, CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.Latest)); compilation = compilation.RemoveAllSyntaxTrees().AddSyntaxTrees(syntaxTree); diff --git a/RadzenBlazorDemos/linker.xml b/RadzenBlazorDemos/linker.xml index 5aa037bd0..b8cc68b7a 100644 --- a/RadzenBlazorDemos/linker.xml +++ b/RadzenBlazorDemos/linker.xml @@ -8,5 +8,15 @@ + + + + + + + + + +