Skip to content

Commit e83418d

Browse files
committed
chore: ignore IL2026 in BindableMetadata.g.cs
Context: 559b1f7 Commit 559b1f7 updated `BindableMetadata.g.cs` to ignore IL2111, because `typeof(Type)` in the binding code was emitting it. Turns out, `typeof(Excpetion)` emits a similar IL2026! Error: …/RecommendedMarkup/RecommendedMarkup/obj/Debug/net10.0-browserwasm/Uno.UI.SourceGenerators/Uno.UI.SourceGenerators.BindableTypeProviders.BindableTypeProvidersSourceGenerator/BindableMetadata.g.cs(1086,4): error IL2026: Using member 'System.Exception.TargetSite.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. which is flagged on this line of code: bindableType.AddProperty("Error", typeof(global::System.Exception), GetError); This was encountered from uno.templates CI when building the output of: dotnet new unoapp -n RecommendedMarkupDsp -skip -preset recommended -markup csharp -dsp Update `BindableTypeProvidersGenerationTask` so that IL2026 is ignored.
1 parent 00cf31c commit e83418d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/SourceGenerators/Uno.UI.SourceGenerators/BindableTypeProviders/BindableTypeProvidersGenerationTask.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ where field.IsStatic
302302
writer.AppendLineIndented("[global::System.Diagnostics.CodeAnalysis.SuppressMessage(\"Microsoft.Maintainability\", \"CA1502:AvoidExcessiveComplexity\", Justification=\"Must be ignored even if generated code is checked.\")]");
303303
writer.AppendLineIndented("[global::System.Diagnostics.CodeAnalysis.SuppressMessage(\"Microsoft.Maintainability\", \"CA1506:AvoidExcessiveClassCoupling\", Justification = \"Must be ignored even if generated code is checked.\")]");
304304
writer.AppendLineIndented("[global::System.Diagnostics.CodeAnalysis.SuppressMessage(\"Microsoft.Maintainability\", \"CA1505:AvoidUnmaintainableCode\", Justification = \"Must be ignored even if generated code is checked.\")]");
305+
writer.AppendLineIndented("[global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage(\"Trimming\", \"IL2026\", Justification = \"`typeof(Exception)` emits IL2026 because of `Exception.TargetSite`, which is not used.\")]");
305306
writer.AppendLineIndented("[global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage(\"Trimming\", \"IL2111\", Justification = \"`typeof(Type)` emits IL2111 because of `Type.TypeInitializer`, which is not used.\")]");
306307
using (writer.BlockInvariant("internal static global::Uno.UI.DataBinding.IBindableType Build(global::Uno.UI.DataBinding.BindableType parent)"))
307308
{

0 commit comments

Comments
 (0)