diff --git a/src/Controls/src/SourceGen/CompiledBindingMarkup.cs b/src/Controls/src/SourceGen/CompiledBindingMarkup.cs index 3b4d067cbe0f..38cbd6d404c1 100644 --- a/src/Controls/src/SourceGen/CompiledBindingMarkup.cs +++ b/src/Controls/src/SourceGen/CompiledBindingMarkup.cs @@ -178,7 +178,7 @@ public bool TryCompileBinding(ITypeSymbol sourceType, bool isTemplateBinding, ou // TypedBinding creation code.WriteLine($"return new global::Microsoft.Maui.Controls.Internals.TypedBinding<{binding.SourceType}, {binding.PropertyType}>("); code.Indent++; - var targetNullValueExpression = isTemplateBinding || !propertyFlags.HasFlag(BindingPropertyFlags.FallbackValue) ? null : "extension.TargetNullValue"; + var targetNullValueExpression = isTemplateBinding || !propertyFlags.HasFlag(BindingPropertyFlags.TargetNullValue) ? null : "extension.TargetNullValue"; code.WriteLine($"getter: source => ({GenerateGetterExpression(binding, sourceVariableName: "source", targetNullValueExpression)}, true),"); code.WriteLine("setter,"); code.Write("handlers: "); diff --git a/src/Controls/src/SourceGen/KnownMarkups.cs b/src/Controls/src/SourceGen/KnownMarkups.cs index a706bcb34d60..32c307576618 100644 --- a/src/Controls/src/SourceGen/KnownMarkups.cs +++ b/src/Controls/src/SourceGen/KnownMarkups.cs @@ -214,7 +214,7 @@ internal static bool ProvideValueForStyleSheetExtension(ElementNode markupNode, else // sourceNode != null { var source = (string)(sourceNode as ValueNode)!.Value; - var uri = $"new global::System.Uri(\"{source}\", global::System.UriKind.Relative)"; + var uri = $"new global::System.Uri(@\"{source}\", global::System.UriKind.Relative)"; var rootTargetPath = $"global::Microsoft.Maui.Controls.Xaml.XamlResourceIdAttribute.GetPathForType(typeof({context.RootType.ToFQDisplayString()}))"; var resourcePath = $"global::Microsoft.Maui.Controls.ResourceDictionary.RDSourceTypeConverter.GetResourcePath({uri}, {rootTargetPath})"; diff --git a/src/Controls/src/SourceGen/NodeSGExtensions.cs b/src/Controls/src/SourceGen/NodeSGExtensions.cs index 87ce892af5bc..b58c7dd8f597 100644 --- a/src/Controls/src/SourceGen/NodeSGExtensions.cs +++ b/src/Controls/src/SourceGen/NodeSGExtensions.cs @@ -447,7 +447,7 @@ void reportDiagnostic() reportDiagnostic(); } if (toType.Equals(context.Compilation.GetTypeByMetadataName("System.Uri")!, SymbolEqualityComparer.Default)) - return $"new global::System.Uri(\"{valueString}\", global::System.UriKind.RelativeOrAbsolute)"; + return $"new global::System.Uri(@\"{valueString}\", global::System.UriKind.RelativeOrAbsolute)"; //default return SymbolDisplay.FormatLiteral(valueString, true); diff --git a/src/Controls/src/SourceGen/TypeConverters/RDSourceConverter.cs b/src/Controls/src/SourceGen/TypeConverters/RDSourceConverter.cs index 9db8f347506c..8d8df72427dd 100644 --- a/src/Controls/src/SourceGen/TypeConverters/RDSourceConverter.cs +++ b/src/Controls/src/SourceGen/TypeConverters/RDSourceConverter.cs @@ -61,7 +61,7 @@ static string GetResourcePath(string value, string rootTargetPath) var uriType = context.Compilation.GetTypeByMetadataName("System.Uri")!; var uriKindType = context.Compilation.GetTypeByMetadataName("System.UriKind")!; - writer.WriteLine($"var {uriVar} = new {uriType.ToFQDisplayString()}(\"{value};assembly={asm.Name}\", {uriKindType.ToFQDisplayString()}.RelativeOrAbsolute);"); + writer.WriteLine($"var {uriVar} = new {uriType.ToFQDisplayString()}(@\"{value};assembly={asm.Name}\", {uriKindType.ToFQDisplayString()}.RelativeOrAbsolute);"); var rootTargetPath = context.ProjectItem.RelativePath!.Replace('\\', '/'); @@ -76,7 +76,7 @@ static string GetResourcePath(string value, string rootTargetPath) else { var resourceDictionaryHelpersType = context.Compilation.GetTypeByMetadataName("Microsoft.Maui.Controls.Xaml.ResourceDictionaryHelpers")!; - writer.WriteLine($"{resourceDictionaryHelpersType.ToFQDisplayString()}.LoadFromSource({parentVar.ValueAccessor}, {uriVar}, \"{GetResourcePath(value, rootTargetPath)}\", typeof({context.RootType.ToFQDisplayString()}).Assembly, null);"); + writer.WriteLine($"{resourceDictionaryHelpersType.ToFQDisplayString()}.LoadFromSource({parentVar.ValueAccessor}, {uriVar}, @\"{GetResourcePath(value, rootTargetPath)}\", typeof({context.RootType.ToFQDisplayString()}).Assembly, null);"); } return uriVar; diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CircularReferenceExtension.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CircularReferenceExtension.cs index 8acfe19dcd04..db5a91a34aa0 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CircularReferenceExtension.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CircularReferenceExtension.cs @@ -155,7 +155,7 @@ public BugPage() // Run generator with BOTH files at once - this creates the shared context // that triggers the infinite loop with the buggy code - var result = RunGenerator(compilation, expanderFile, bugFile); + var result = RunGenerator(compilation, [expanderFile, bugFile]); return result; }, cts.Token); diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs index 0dd59a06158d..e01d051e3365 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/CompiledBindings.cs @@ -489,6 +489,156 @@ public class Product Assert.False(result.Diagnostics.Any(d => d.Severity == Microsoft.CodeAnalysis.DiagnosticSeverity.Error)); } + [Fact] + public void TargetNullValueWithNullablePathGeneratesValidCode() + { + // This test reproduces the issue from #32606 where TargetNullValue with nullable path + // generates invalid code: getter references extension.TargetNullValue but cannot be static + var xaml = +""" + + + +"""; + + var code = +""" +#nullable enable +using System; +using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Xaml; + +namespace Test; + +[XamlProcessing(XamlInflator.SourceGen)] +public partial class TestPage : ContentPage +{ + public Person? CurrentPerson { get; set; } = null; + + public TestPage() + { + InitializeComponent(); + } +} + +public class Person +{ + public int Id { get; set; } +} +"""; + var testXamlFilePath = Path.Combine(Environment.CurrentDirectory, "Test.xaml"); + var expected = $$""" +//------------------------------------------------------------------------------ +// +// This code was generated by a .NET MAUI source generator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +#nullable enable + +namespace Test; + +[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Maui.Controls.SourceGen, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null", "10.0.0.0")] +public partial class TestPage +{ + private partial void InitializeComponent() + { + // Fallback to Runtime inflation if the page was updated by HotReload + static string? getPathForType(global::System.Type type) + { + var assembly = type.Assembly; + foreach (var xria in global::System.Reflection.CustomAttributeExtensions.GetCustomAttributes(assembly)) + { + if (xria.Type == type) + return xria.Path; + } + return null; + } + + var rlr = global::Microsoft.Maui.Controls.Internals.ResourceLoader.ResourceProvider2?.Invoke(new global::Microsoft.Maui.Controls.Internals.ResourceLoader.ResourceLoadingQuery + { + AssemblyName = typeof(global::Test.TestPage).Assembly.GetName(), + ResourcePath = getPathForType(typeof(global::Test.TestPage)), + Instance = this, + }); + + if (rlr?.ResourceContent != null) + { + this.InitializeComponentRuntime(); + return; + } + + var bindingExtension = new global::Microsoft.Maui.Controls.Xaml.BindingExtension(); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingExtension!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 8, 9); + var label = new global::Microsoft.Maui.Controls.Label(); + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(label!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 8, 3); + var __root = this; + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(__root!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 2, 2); +#if !_MAUIXAML_SG_NAMESCOPE_DISABLE + global::Microsoft.Maui.Controls.Internals.INameScope iNameScope = global::Microsoft.Maui.Controls.Internals.NameScope.GetNameScope(__root) ?? new global::Microsoft.Maui.Controls.Internals.NameScope(); +#endif +#if !_MAUIXAML_SG_NAMESCOPE_DISABLE + global::Microsoft.Maui.Controls.Internals.NameScope.SetNameScope(__root, iNameScope); +#endif +#if !_MAUIXAML_SG_NAMESCOPE_DISABLE + label.transientNamescope = iNameScope; +#endif +#line 8 "{{testXamlFilePath}}" + bindingExtension.TargetNullValue = "0"; +#line default +#line 8 "{{testXamlFilePath}}" + bindingExtension.Path = "CurrentPerson.Id"; +#line default + var bindingBase = CreateTypedBindingFrom_bindingExtension(bindingExtension); + if (global::Microsoft.Maui.VisualDiagnostics.GetSourceInfo(bindingBase!) == null) + global::Microsoft.Maui.VisualDiagnostics.RegisterSourceInfo(bindingBase!, new global::System.Uri(@"Test.xaml;assembly=SourceGeneratorDriver.Generated", global::System.UriKind.Relative), 8, 9); + label.SetBinding(global::Microsoft.Maui.Controls.Label.TextProperty, bindingBase); +#line 8 "{{testXamlFilePath}}" + __root.SetValue(global::Microsoft.Maui.Controls.ContentPage.ContentProperty, label); +#line default + static global::Microsoft.Maui.Controls.BindingBase CreateTypedBindingFrom_bindingExtension(global::Microsoft.Maui.Controls.Xaml.BindingExtension extension) + { + global::System.Action? setter = static (source, value) => + { + if (source.CurrentPerson is {} p0) + { + p0.Id = value; + } + }; + + return new global::Microsoft.Maui.Controls.Internals.TypedBinding( + getter: source => (source.CurrentPerson?.Id ?? extension.TargetNullValue as int? ?? default, true), + setter, + handlers: new global::System.Tuple, string>[] + { + new(static source => source, "CurrentPerson"), + new(static source => source.CurrentPerson, "Id"), + }) + { + TargetNullValue = extension.TargetNullValue, + }; + } + + + } +} + +"""; + + var (result, generated) = RunGenerator(xaml, code); + + // Verify the generated code matches expected structure + CodeIsEqual(expected, generated ?? string.Empty); + } + [Theory] [InlineData("{Binding .}")] [InlineData("{Binding}")] diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/LineInfoTests.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/LineInfoTests.cs index 346d61377421..42e5111df425 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/LineInfoTests.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/LineInfoTests.cs @@ -58,6 +58,6 @@ public void LineInfoDisabledDefault() var generatedCode = result.GeneratedTrees.Single(tree => Path.GetFileName(tree.FilePath) == "Test.xaml.xsg.cs").ToString(); var expectedFilePath = Path.Combine(Environment.CurrentDirectory, "Test.xaml"); - Assert.False(generatedCode.Contains(@$"#line 9 ""{expectedFilePath}""", StringComparison.Ordinal)); + Assert.False(generatedCode.Contains(@$"#line 9 ""{expectedFilePath}""", StringComparison.Ordinal)); } } diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SourceGenXamlInitializeComponentTests.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SourceGenXamlInitializeComponentTests.cs index f4fd18cfe109..e7f24b56d987 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SourceGenXamlInitializeComponentTests.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/SourceGenXamlInitializeComponentTests.cs @@ -16,13 +16,13 @@ public class SourceGenXamlInitializeComponentTestBase : SourceGenTestsBase protected record AdditionalXamlFile(string Path, string Content, string? RelativePath = null, string? TargetPath = null, string? ManifestResourceName = null, string? TargetFramework = null, string? NoWarn = null, string Lineinfo = "enable") : AdditionalFile(Text: ToAdditionalText(Path, Content), Kind: "Xaml", RelativePath: RelativePath ?? Path, TargetPath: TargetPath, ManifestResourceName: ManifestResourceName, TargetFramework: TargetFramework, NoWarn: NoWarn, LineInfo: Lineinfo); - protected (GeneratorDriverRunResult result, string? text) RunGenerator(string xaml, string code, string noWarn = "", string targetFramework = "", string? path = null, string lineinfo = "enable") + protected (GeneratorDriverRunResult result, string? text) RunGenerator(string xaml, string code, string noWarn = "", string targetFramework = "", string? path = null, string lineinfo = "enable", bool assertNoCompilationErrors = true) { var compilation = CreateMauiCompilation(); compilation = compilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(code)); var workingDirectory = Environment.CurrentDirectory; var xamlFile = new AdditionalXamlFile(Path.Combine(workingDirectory, path ?? "Test.xaml"), xaml, RelativePath: path ?? "Test.xaml", TargetFramework: targetFramework, NoWarn: noWarn, ManifestResourceName: $"{compilation.AssemblyName}.Test.xaml", Lineinfo: lineinfo); - var result = RunGenerator(compilation, xamlFile); + var result = RunGenerator(compilation, xamlFile, assertNoCompilationErrors); var generated = result.Results.SingleOrDefault().GeneratedSources.SingleOrDefault(gs => gs.HintName.EndsWith(".xsg.cs")).SourceText?.ToString(); return (result, generated); diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/UnresolvedType.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/UnresolvedType.cs index b60f2c643770..be1b1f4208e8 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/UnresolvedType.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/UnresolvedType.cs @@ -130,7 +130,7 @@ private partial void InitializeComponent() """; - var (result, generated) = RunGenerator(xaml, code); + var (result, generated) = RunGenerator(xaml, code, assertNoCompilationErrors: false); Assert.False(result.Diagnostics.Any()); Assert.Equal(expected, generated, ignoreLineEndingDifferences: true); } diff --git a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/XStaticUnresolvedType.cs b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/XStaticUnresolvedType.cs index 15fe6775563e..3fb44500064a 100644 --- a/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/XStaticUnresolvedType.cs +++ b/src/Controls/tests/SourceGen.UnitTests/InitializeComponent/XStaticUnresolvedType.cs @@ -27,14 +27,23 @@ public void XStaticWithClrNamespace() using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Xaml; -namespace Test; +namespace Test +{ + [XamlProcessing(XamlInflator.SourceGen)] + partial class TestPage : ContentPage + { + public TestPage() + { + InitializeComponent(); + } + } +} -[XamlProcessing(XamlInflator.SourceGen)] -partial class TestPage : ContentPage +namespace MyApp.Routes { - public TestPage() + public static class Route { - InitializeComponent(); + public static string Value => "TestRoute"; } } """; @@ -110,7 +119,7 @@ private partial void InitializeComponent() """; - var (result, generated) = RunGenerator(xaml, code); + var (result, generated) = RunGenerator(xaml, code, assertNoCompilationErrors: true); Assert.False(result.Diagnostics.Any()); Assert.Equal(expected, generated, ignoreLineEndingDifferences: true); } @@ -135,14 +144,23 @@ public void XStaticWithClrNamespaceAndAssembly() using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Xaml; -namespace Test; +namespace Test +{ + [XamlProcessing(XamlInflator.SourceGen)] + partial class TestPage : ContentPage + { + public TestPage() + { + InitializeComponent(); + } + } +} -[XamlProcessing(XamlInflator.SourceGen)] -partial class TestPage : ContentPage +namespace ExternalLib.Constants { - public TestPage() + public static class AppConstants { - InitializeComponent(); + public static string AppName => "TestApp"; } } """; @@ -218,7 +236,7 @@ private partial void InitializeComponent() """; - var (result, generated) = RunGenerator(xaml, code); + var (result, generated) = RunGenerator(xaml, code, assertNoCompilationErrors: true); Assert.False(result.Diagnostics.Any()); Assert.Equal(expected, generated, ignoreLineEndingDifferences: true); } @@ -243,14 +261,23 @@ public void XStaticWithClrNamespaceFieldAccess() using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Xaml; -namespace Test; +namespace Test +{ + [XamlProcessing(XamlInflator.SourceGen)] + partial class TestPage : ContentPage + { + public TestPage() + { + InitializeComponent(); + } + } +} -[XamlProcessing(XamlInflator.SourceGen)] -partial class TestPage : ContentPage +namespace MyApp.Config { - public TestPage() + public static class Settings { - InitializeComponent(); + public static double DefaultFontSize => 14.0; } } """; @@ -326,7 +353,7 @@ private partial void InitializeComponent() """; - var (result, generated) = RunGenerator(xaml, code); + var (result, generated) = RunGenerator(xaml, code, assertNoCompilationErrors: true); Assert.False(result.Diagnostics.Any()); Assert.Equal(expected, generated, ignoreLineEndingDifferences: true); } diff --git a/src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs b/src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs index 55fd32cb92c4..0a508aff0e4d 100644 --- a/src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs +++ b/src/Controls/tests/SourceGen.UnitTests/SourceGeneratorDriver.cs @@ -19,8 +19,11 @@ public static class SourceGeneratorDriver private static MetadataReference[]? MauiReferences; public record AdditionalFile(AdditionalText Text, string Kind, string RelativePath, string? TargetPath, string? ManifestResourceName, string? TargetFramework, string? NoWarn, string LineInfo="enable"); + public static GeneratorDriverRunResult RunGenerator(Compilation compilation, AdditionalFile additionalFile, bool assertNoCompilationErrors = true) + where T : IIncrementalGenerator, new() + => RunGenerator(compilation, additionalFiles: [additionalFile], assertNoCompilationErrors); - public static GeneratorDriverRunResult RunGenerator(Compilation compilation, params AdditionalFile[] additionalFiles) + public static GeneratorDriverRunResult RunGenerator(Compilation compilation, AdditionalFile[] additionalFiles, bool assertNoCompilationErrors = true) where T : IIncrementalGenerator, new() { ISourceGenerator generator = new T().AsSourceGenerator(); @@ -34,9 +37,26 @@ public static GeneratorDriverRunResult RunGenerator(Compilation compilation, .AddAdditionalTexts([.. additionalFiles.Select(f => f.Text)]) .WithUpdatedAnalyzerConfigOptions(new CustomAnalyzerConfigOptionsProvider(additionalFiles)); - driver = driver.RunGenerators(compilation); + // Use RunGeneratorsAndUpdateCompilation to validate the generated code + // This will catch C# compilation errors in the generated code + driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var updatedCompilation, out var diagnostics); + + // Assert that the generated code compiles without errors (if requested) + if (assertNoCompilationErrors) + { + var compilationErrors = updatedCompilation.GetDiagnostics() + .Where(d => d.Severity == DiagnosticSeverity.Error) + .Where(d => d.Location.SourceTree?.FilePath?.EndsWith(".xsg.cs", StringComparison.OrdinalIgnoreCase) == true) + .ToArray(); + + if (compilationErrors.Length > 0) + { + var errorMessages = string.Join(Environment.NewLine, compilationErrors.Select(e => $"{e.Id}: {e.GetMessage()} at {e.Location}")); + throw new InvalidOperationException($"Generated code has compilation errors:{Environment.NewLine}{errorMessages}"); + } + } - GeneratorDriverRunResult runResult = driver.GetRunResult(); + var runResult = driver.GetRunResult(); return runResult; } @@ -82,26 +102,28 @@ private static MetadataReference[] GetMauiReferences() { string dotNetAssemblyPath = Path.GetDirectoryName(typeof(object).Assembly.Location)!; - if (MauiReferences == null) - { - MauiReferences = new[] - { - MetadataReference.CreateFromFile(typeof(InternalsVisibleToAttribute).Assembly.Location), - // .NET assemblies are finicky and need to be loaded in a special way. - MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "mscorlib.dll")), - MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.dll")), - MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.Core.dll")), - MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.Private.CoreLib.dll")), - MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.Runtime.dll")), - MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.ObjectModel.dll")), - MetadataReference.CreateFromFile(typeof(Uri).Assembly.Location), //System.Private.Uri - MetadataReference.CreateFromFile(typeof(Color).Assembly.Location), //Graphics - MetadataReference.CreateFromFile(typeof(Button).Assembly.Location), //Controls - MetadataReference.CreateFromFile(typeof(BindingExtension).Assembly.Location), //Xaml - MetadataReference.CreateFromFile(typeof(Thickness).Assembly.Location), //Core - MetadataReference.CreateFromFile(typeof(Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebView).Assembly.Location), //Xaml.dll - }; - } + MauiReferences ??= + [ + MetadataReference.CreateFromFile(typeof(InternalsVisibleToAttribute).Assembly.Location), + // .NET assemblies are finicky and need to be loaded in a special way. + MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "mscorlib.dll")), + MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.dll")), + MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.Core.dll")), + MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.Private.CoreLib.dll")), + MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.Runtime.dll")), + MetadataReference.CreateFromFile(Path.Combine(dotNetAssemblyPath, "System.ObjectModel.dll")), + MetadataReference.CreateFromFile(typeof(Uri).Assembly.Location), //System.Private.Uri + MetadataReference.CreateFromFile(typeof(Color).Assembly.Location), //Graphics + MetadataReference.CreateFromFile(typeof(Button).Assembly.Location), //Controls + MetadataReference.CreateFromFile(typeof(BindingExtension).Assembly.Location), //Xaml + MetadataReference.CreateFromFile(typeof(Thickness).Assembly.Location), //Core + MetadataReference.CreateFromFile(typeof(Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebView).Assembly.Location), //Xaml.dll + MetadataReference.CreateFromFile(System.Reflection.Assembly.Load("System.Private.Xml").Location), + MetadataReference.CreateFromFile(System.Reflection.Assembly.Load("System.Xml.ReaderWriter").Location), + MetadataReference.CreateFromFile(typeof(System.IServiceProvider).Assembly.Location), //System.ComponentModel + MetadataReference.CreateFromFile(typeof(System.ComponentModel.TypeConverter).Assembly.Location), //System.ComponentModel.TypeConverter + ]; + return MauiReferences; }