Skip to content

Commit

Permalink
Create development path without compatibility projects (#13660)
Browse files Browse the repository at this point in the history
  • Loading branch information
PureWeen authored Mar 15, 2023
1 parent e35b10f commit 474d332
Show file tree
Hide file tree
Showing 33 changed files with 936 additions and 96 deletions.
7 changes: 5 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<_MauiDotNetVersionMinor Condition="'$(_MauiDotNetVersionMinor)' == ''">0</_MauiDotNetVersionMinor>
<_MauiDotNetVersion Condition="'$(_MauiDotNetVersion)' == ''">$(_MauiDotNetVersionMajor).$(_MauiDotNetVersionMinor)</_MauiDotNetVersion>
<_MauiDotNetTfm Condition="'$(_MauiDotNetTfm)' == ''">net$(_MauiDotNetVersion)</_MauiDotNetTfm>

<_MauiPreviousDotNetVersionMajor Condition="'$(_MauiPreviousDotNetVersionMajor)' == ''">6</_MauiPreviousDotNetVersionMajor>
<_MauiPreviousDotNetVersionMinor Condition="'$(_MauiPreviousDotNetVersionMinor)' == ''">0</_MauiPreviousDotNetVersionMinor>
<_MauiPreviousDotNetVersion Condition="'$(_MauiPreviousDotNetVersion)' == ''">$(_MauiPreviousDotNetVersionMajor).$(_MauiPreviousDotNetVersionMinor)</_MauiPreviousDotNetVersion>
<_MauiPreviousDotNetVersionNoDot Condition="'$(_MauiPreviousDotNetVersionNoDot)' == ''">$(_MauiPreviousDotNetVersionMajor)$(_MauiPreviousDotNetVersionMinor)</_MauiPreviousDotNetVersionNoDot>
<_MauiPreviousDotNetTfm Condition="'$(_MauiPreviousDotNetTfm)' == ''">net$(_MauiPreviousDotNetVersion)</_MauiPreviousDotNetTfm>

<_MauiTargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</_MauiTargetPlatformIdentifier>
<_MauiNoTargetPlatform>false</_MauiNoTargetPlatform>
<_MauiNoTargetPlatform Condition="'$(_MauiTargetPlatformIdentifier)' == ''">True</_MauiNoTargetPlatform>
Expand Down Expand Up @@ -57,6 +57,8 @@
<IncludeAndroidTargetFrameworks>true</IncludeAndroidTargetFrameworks>
<IncludeMacCatalystTargetFrameworks>true</IncludeMacCatalystTargetFrameworks>
<IncludeIosTargetFrameworks>true</IncludeIosTargetFrameworks>
<IncludeCompatibilityProjects>false</IncludeCompatibilityProjects>
<IncludeCompatibilityProjects Condition="'$(SolutionFileName)' == 'Microsoft.Maui.sln'">true</IncludeCompatibilityProjects>
</PropertyGroup>

<!-- this is CI, so everything should be there -->
Expand All @@ -71,6 +73,7 @@

<PropertyGroup>
<DefineConstants Condition="'$(_MauiTargetPlatformIsWindows)' == 'True'">$(DefineConstants);WINDOWS</DefineConstants>
<DefineConstants Condition="'$(IncludeCompatibilityProjects)' == 'True'">$(DefineConstants);COMPATIBILITY_ENABLED</DefineConstants>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<!-- <GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles> -->
<!-- HACK: WinUI seems to have issues without this -->
Expand Down
606 changes: 606 additions & 0 deletions Microsoft.Maui-dev.sln

Large diffs are not rendered by default.

18 changes: 3 additions & 15 deletions Microsoft.Maui-mac.slnf
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
{
"solution": {
"path": "Microsoft.Maui.sln",
"path": "Microsoft.Maui-dev.sln",
"projects": [
"src\\BlazorWebView\\samples\\MauiRazorClassLibrarySample\\MauiRazorClassLibrarySample.csproj",
"src\\BlazorWebView\\samples\\WebViewAppShared\\WebViewAppShared.csproj",
"src\\BlazorWebView\\src\\Maui\\Microsoft.AspNetCore.Components.WebView.Maui.csproj",
"src\\BlazorWebView\\tests\\MauiDeviceTests\\MauiBlazorWebView.DeviceTests.csproj",
"src\\Compatibility\\Android.AppLinks\\src\\Compatibility.Android.AppLinks.csproj",
"src\\Compatibility\\ControlGallery\\src\\Android\\Compatibility.ControlGallery.Android.csproj",
"src\\Compatibility\\ControlGallery\\src\\Core\\Compatibility.ControlGallery.Core.csproj",
"src\\Compatibility\\ControlGallery\\src\\Issues.Shared\\Compatibility.ControlGallery.Issues.Shared.shproj",
"src\\Compatibility\\ControlGallery\\src\\UITests.Shared\\Compatibility.UITests.Shared.shproj",
"src\\Compatibility\\ControlGallery\\src\\iOS\\Compatibility.ControlGallery.iOS.csproj",
"src\\Compatibility\\ControlGallery\\test\\Android.UITests\\Compatibility.ControlGallery.Android.UITests.csproj",
"src\\Compatibility\\ControlGallery\\test\\iOS.UITests\\Compatibility.ControlGallery.iOS.UITests.csproj",
"src\\Compatibility\\Core\\src\\Compatibility.csproj",
"src\\Compatibility\\Core\\tests\\Android\\Compatibility.Android.UnitTests.csproj",
"src\\Compatibility\\Core\\tests\\iOS\\Compatibility.iOS.UnitTests.csproj",
"src\\Compatibility\\Maps\\src\\Android\\Compatibility.Maps.Android.csproj",
"src\\Compatibility\\Maps\\src\\iOS\\Compatibility.Maps.iOS.csproj",
"src\\Controls\\Foldable\\src\\Controls.Foldable.csproj",
"src\\Controls\\Maps\\src\\Controls.Maps.csproj",
"src\\Controls\\samples\\Controls.Sample.Profiling\\Maui.Controls.Sample.Profiling.csproj",
Expand All @@ -34,6 +21,7 @@
"src\\Controls\\tests\\Core.UnitTests\\Controls.Core.UnitTests.csproj",
"src\\Controls\\tests\\CustomAttributes\\Controls.CustomAttributes.csproj",
"src\\Controls\\tests\\DeviceTests\\Controls.DeviceTests.csproj",
"src\\Controls\\tests\\Xaml.UnitTests.ExternalAssembly\\Controls.Xaml.UnitTests.ExternalAssembly.csproj",
"src\\Controls\\tests\\Xaml.UnitTests\\Controls.Xaml.UnitTests.csproj",
"src\\Core\\maps\\src\\Maps.csproj",
"src\\Core\\src\\Core.csproj",
Expand All @@ -48,8 +36,8 @@
"src\\Essentials\\test\\UnitTests\\Essentials.UnitTests.csproj",
"src\\Graphics\\src\\Graphics.Skia\\Graphics.Skia.csproj",
"src\\Graphics\\src\\Graphics\\Graphics.csproj",
"src\\Graphics\\tests\\DeviceTests\\Graphics.DeviceTests.csproj",
"src\\Graphics\\src\\Text.Markdig\\Graphics.Text.Markdig.csproj",
"src\\Graphics\\tests\\DeviceTests\\Graphics.DeviceTests.csproj",
"src\\SingleProject\\Resizetizer\\src\\Resizetizer.csproj",
"src\\SingleProject\\Resizetizer\\test\\UnitTests\\Resizetizer.UnitTests.csproj",
"src\\Templates\\src\\Microsoft.Maui.Templates.csproj",
Expand Down
70 changes: 70 additions & 0 deletions Microsoft.Maui-windows.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"solution": {
"path": "Microsoft.Maui-dev.sln",
"projects": [
"src\\BlazorWebView\\samples\\BlazorWinFormsApp\\BlazorWinFormsApp.csproj",
"src\\BlazorWebView\\samples\\BlazorWpfApp\\BlazorWpfApp.csproj",
"src\\BlazorWebView\\samples\\MauiRazorClassLibrarySample\\MauiRazorClassLibrarySample.csproj",
"src\\BlazorWebView\\samples\\WebViewAppShared\\WebViewAppShared.csproj",
"src\\BlazorWebView\\src\\Maui\\Microsoft.AspNetCore.Components.WebView.Maui.csproj",
"src\\BlazorWebView\\src\\WindowsForms\\Microsoft.AspNetCore.Components.WebView.WindowsForms.csproj",
"src\\BlazorWebView\\src\\Wpf\\Microsoft.AspNetCore.Components.WebView.Wpf.csproj",
"src\\BlazorWebView\\tests\\MauiDeviceTests\\MauiBlazorWebView.DeviceTests.csproj",
"src\\Controls\\Foldable\\src\\Controls.Foldable.csproj",
"src\\Controls\\Maps\\src\\Controls.Maps.csproj",
"src\\Controls\\samples\\Controls.Sample.Profiling\\Maui.Controls.Sample.Profiling.csproj",
"src\\Controls\\samples\\Controls.Sample.Sandbox\\Maui.Controls.Sample.Sandbox.csproj",
"src\\Controls\\samples\\Controls.Sample\\Maui.Controls.Sample.csproj",
"src\\Controls\\src\\Build.Tasks\\Controls.Build.Tasks.csproj",
"src\\Controls\\src\\Core.Design\\Controls.Core.Design.csproj",
"src\\Controls\\src\\Core\\Controls.Core.csproj",
"src\\Controls\\src\\NuGet\\Controls.NuGet.csproj",
"src\\Controls\\src\\SourceGen\\Controls.SourceGen.csproj",
"src\\Controls\\src\\Xaml.Design\\Controls.Xaml.Design.csproj",
"src\\Controls\\src\\Xaml\\Controls.Xaml.csproj",
"src\\Controls\\tests\\Core.Design.UnitTests\\Controls.Core.Design.UnitTests.csproj",
"src\\Controls\\tests\\Core.UnitTests\\Controls.Core.UnitTests.csproj",
"src\\Controls\\tests\\CustomAttributes\\Controls.CustomAttributes.csproj",
"src\\Controls\\tests\\DeviceTests\\Controls.DeviceTests.csproj",
"src\\Controls\\tests\\Xaml.UnitTests.ExternalAssembly\\Controls.Xaml.UnitTests.ExternalAssembly.csproj",
"src\\Controls\\tests\\Xaml.UnitTests\\Controls.Xaml.UnitTests.csproj",
"src\\Core\\maps\\src\\Maps.csproj",
"src\\Core\\src\\Core.csproj",
"src\\Core\\tests\\Benchmarks.Droid\\Benchmarks.Droid.csproj",
"src\\Core\\tests\\Benchmarks\\Core.Benchmarks.csproj",
"src\\Core\\tests\\DeviceTests.Shared\\Core.DeviceTests.Shared.csproj",
"src\\Core\\tests\\DeviceTests\\Core.DeviceTests.csproj",
"src\\Core\\tests\\UnitTests\\Core.UnitTests.csproj",
"src\\Essentials\\samples\\Sample.Server.WebAuthenticator\\Essentials.Sample.Server.WebAuthenticator.csproj",
"src\\Essentials\\samples\\Samples\\Essentials.Sample.csproj",
"src\\Essentials\\src\\Essentials.csproj",
"src\\Essentials\\test\\DeviceTests\\Essentials.DeviceTests.csproj",
"src\\Essentials\\test\\UnitTests\\Essentials.UnitTests.csproj",
"src\\Graphics\\samples\\GraphicsTester.Android\\GraphicsTester.Android.csproj",
"src\\Graphics\\samples\\GraphicsTester.Portable\\GraphicsTester.Portable.csproj",
"src\\Graphics\\samples\\GraphicsTester.Skia.Console\\GraphicsTester.Skia.Console.csproj",
"src\\Graphics\\samples\\GraphicsTester.Skia.Tizen\\GraphicsTester.Skia.Tizen.csproj",
"src\\Graphics\\samples\\GraphicsTester.Skia.Windows\\GraphicsTester.Skia.Windows.csproj",
"src\\Graphics\\samples\\GraphicsTester.WinUI.Desktop\\GraphicsTester.WinUI.Desktop.csproj",
"src\\Graphics\\samples\\GraphicsTester.iOS\\GraphicsTester.iOS.csproj",
"src\\Graphics\\src\\Graphics.Skia.WPF\\Graphics.Skia.WPF.csproj",
"src\\Graphics\\src\\Graphics.Skia\\Graphics.Skia.csproj",
"src\\Graphics\\src\\Graphics.Win2D\\Graphics.Win2D.csproj",
"src\\Graphics\\src\\Graphics\\Graphics.csproj",
"src\\Graphics\\src\\Text.Markdig\\Graphics.Text.Markdig.csproj",
"src\\Graphics\\tests\\DeviceTests\\Graphics.DeviceTests.csproj",
"src\\Graphics\\tests\\Graphics.Benchmarks\\Graphics.Benchmarks.csproj",
"src\\Graphics\\tests\\Graphics.Tests\\Graphics.Tests.csproj",
"src\\SingleProject\\Resizetizer\\src\\Resizetizer.csproj",
"src\\SingleProject\\Resizetizer\\test\\UnitTests\\Resizetizer.UnitTests.csproj",
"src\\Templates\\src\\Microsoft.Maui.Templates.csproj",
"src\\TestUtils\\samples\\DeviceTests.Sample\\TestUtils.DeviceTests.Sample.csproj",
"src\\TestUtils\\src\\DeviceTests.Runners.SourceGen\\TestUtils.DeviceTests.Runners.SourceGen.csproj",
"src\\TestUtils\\src\\DeviceTests.Runners\\TestUtils.DeviceTests.Runners.csproj",
"src\\TestUtils\\src\\DeviceTests\\TestUtils.DeviceTests.csproj",
"src\\TestUtils\\src\\TestUtils\\TestUtils.csproj",
"src\\Workload\\Microsoft.Maui.Sdk\\Microsoft.Maui.Sdk.csproj",
"src\\Workload\\Microsoft.NET.Sdk.Maui\\Microsoft.NET.Sdk.Maui.csproj"
]
}
}
14 changes: 14 additions & 0 deletions Microsoft.Maui.sln
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.DeviceTests.Shared", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Graphics.DeviceTests", "src\Graphics\tests\DeviceTests\Graphics.DeviceTests.csproj", "{34969E49-FA6E-41BB-9813-5689BB14021E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Compatibility.Core.UnitTests", "src\Compatibility\Core\tests\Compatibility.UnitTests\Compatibility.Core.UnitTests.csproj", "{13A1AFD2-78D3-4463-9977-C8B642BCE2E2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Controls.Xaml.UnitTests.ExternalAssembly", "src\Controls\tests\Xaml.UnitTests.ExternalAssembly\Controls.Xaml.UnitTests.ExternalAssembly.csproj", "{F2ADA552-6328-4B2D-8D48-FCDD32C4AF60}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -609,6 +613,14 @@ Global
{34969E49-FA6E-41BB-9813-5689BB14021E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34969E49-FA6E-41BB-9813-5689BB14021E}.Release|Any CPU.Build.0 = Release|Any CPU
{34969E49-FA6E-41BB-9813-5689BB14021E}.Release|Any CPU.Deploy.0 = Release|Any CPU
{13A1AFD2-78D3-4463-9977-C8B642BCE2E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13A1AFD2-78D3-4463-9977-C8B642BCE2E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13A1AFD2-78D3-4463-9977-C8B642BCE2E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13A1AFD2-78D3-4463-9977-C8B642BCE2E2}.Release|Any CPU.Build.0 = Release|Any CPU
{F2ADA552-6328-4B2D-8D48-FCDD32C4AF60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2ADA552-6328-4B2D-8D48-FCDD32C4AF60}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2ADA552-6328-4B2D-8D48-FCDD32C4AF60}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2ADA552-6328-4B2D-8D48-FCDD32C4AF60}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -722,6 +734,8 @@ Global
{4A6930AE-B67C-4D29-B1A8-ED9EB7F923A7} = {50C758FE-4E10-409A-94F5-A75480960864}
{66CC98E3-6A1A-4C44-A23C-B575E82106EC} = {C564DDD6-DE79-45CD-88EA-3F690481572A}
{34969E49-FA6E-41BB-9813-5689BB14021E} = {936C47A9-A7EA-4FBD-8733-CED1D4100E69}
{13A1AFD2-78D3-4463-9977-C8B642BCE2E2} = {85EBD2BA-EA5A-4B1F-AF16-81FBD58579DF}
{F2ADA552-6328-4B2D-8D48-FCDD32C4AF60} = {25D0D27A-C5FE-443D-8B65-D6C987F4A80E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B8ABEAD-D2B5-4370-A187-62B5ABE4EE50}
Expand Down
3 changes: 2 additions & 1 deletion eng/cake/dotnet.cake
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ Task("dotnet-test")
"**/Essentials.UnitTests.csproj",
"**/Resizetizer.UnitTests.csproj",
"**/Graphics.Tests.csproj",
"**/Compatibility.Core.UnitTests.csproj",
};

var success = true;
Expand Down Expand Up @@ -628,7 +629,7 @@ void StartVisualStudioForDotNet()
{
if (IsRunningOnWindows())
{
sln = "./Microsoft.Maui.sln";
sln = "./Microsoft.Maui-windows.slnf";
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ProjectReference Include="..\..\..\TestUtils\src\DeviceTests\TestUtils.DeviceTests.csproj" />
<ProjectReference Include="..\..\..\TestUtils\src\DeviceTests.Runners\TestUtils.DeviceTests.Runners.csproj" />
<ProjectReference Include="..\..\..\TestUtils\src\DeviceTests.Runners.SourceGen\TestUtils.DeviceTests.Runners.SourceGen.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\..\Compatibility\Core\src\Compatibility.csproj" />
<ProjectReference Condition="'$(IncludeCompatibilityProjects)' == 'true'" Include="..\..\..\Compatibility\Core\src\Compatibility.csproj" />
<ProjectReference Include="..\..\..\Core\src\Core.csproj" />
<ProjectReference Include="..\..\..\Controls\src\Xaml\Controls.Xaml.csproj" />
<ProjectReference Include="..\..\..\Controls\src\Core\Controls.Core.csproj" />
Expand Down
1 change: 1 addition & 0 deletions src/Compatibility/Core/src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[assembly: InternalsVisibleTo("Compatibility.Windows.UnitTests")]
[assembly: InternalsVisibleTo("Compatibility.Android.UnitTests")]
[assembly: InternalsVisibleTo("Microsoft.Maui.Controls.Core.UnitTests")]
[assembly: InternalsVisibleTo("Microsoft.Maui.Compatibility.Core.UnitTests")]
[assembly: InternalsVisibleTo("Microsoft.Maui.Controls.Xaml.UnitTests")]
[assembly: StyleProperty("column-gap", typeof(CGrid), nameof(CGrid.ColumnSpacingProperty))]
[assembly: StyleProperty("row-gap", typeof(CGrid), nameof(CGrid.RowSpacingProperty))]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using Microsoft.Maui.ApplicationModel;

namespace Microsoft.Maui.Compatibility.Core.UnitTests
{
class ApplicationStub : IApplication
{
readonly List<IWindow> _windows = new List<IWindow>();

public IElementHandler Handler { get; set; }

public Maui.IElement Parent { get; set; }

public IReadOnlyList<IWindow> Windows => _windows.AsReadOnly();

public string Property { get; set; } = "Default";

public AppTheme UserAppTheme { get; set; }

public IWindow CreateWindow(IActivationState activationState)
{
throw new System.NotImplementedException();
}

public void OpenWindow(IWindow window)
{
_windows.Add(window);
}

public void CloseWindow(IWindow window)
{
_windows.Remove(window);
}

public void ThemeChanged() { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using Microsoft.Maui.Handlers;

namespace Microsoft.Maui.Compatibility.Core.UnitTests
{
class ButtonHandlerStub : ViewHandler<IButton, object>
{
protected override object CreatePlatformView() => throw new NotImplementedException();
public ButtonHandlerStub() : base(new PropertyMapper<IButton, ButtonHandlerStub>())
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(_MauiDotNetTfm)</TargetFramework>
<AssemblyName>Microsoft.Maui.Compatibility.Core.UnitTests</AssemblyName>
<IsPackable>false</IsPackable>
<NoWarn>0114;0672;0108;0067;0168;0169;0219;0612;0618;1998;4014</NoWarn>
<RootNamespace>Microsoft.Maui.Compatibility.Core.UnitTests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="NSubstitute" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Controls\src\Core\Controls.Core.csproj" />
<ProjectReference Include="..\..\..\..\Core\src\Core.csproj" />
<ProjectReference Include="..\..\..\..\TestUtils\src\TestUtils\TestUtils.csproj" />
<ProjectReference Include="..\..\src\Compatibility.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui.Controls.Compatibility.Hosting;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
using Xunit;

namespace Microsoft.Maui.Compatibility.Core.UnitTests
{
public class HostBuilderAppTests
{
[Theory]
[InlineData(true)]
[InlineData(false)]
public void CompatibilityExtensionsWorkUseCompatibility(bool useCompatibility)
{
MauiAppBuilderExtensions.ResetCompatibilityCheck();
bool handlersCalled = false;
var builder = MauiApp.CreateBuilder().UseMauiApp<ApplicationStub>();

if (useCompatibility)
builder = builder.UseMauiCompatibility();

var mauiApp =
builder.ConfigureMauiHandlers(collection =>
{
handlersCalled = true;

if (useCompatibility)
{
collection.AddCompatibilityRenderer(typeof(Object), typeof(Object));
}
else
{
Assert.Throws<InvalidOperationException>(() =>
collection.AddCompatibilityRenderer(typeof(Object), typeof(Object))
);
}
})
.Build();

_ = mauiApp.Services.GetRequiredService<IMauiHandlersFactory>();
Assert.True(handlersCalled);
}

[Fact]
public void RegisteringHandlerWithAddCompatibilityRendererThrowsException()
{
MauiAppBuilderExtensions.ResetCompatibilityCheck();
bool handlersCalled = false;
var builder = MauiApp.CreateBuilder().UseMauiApp<ApplicationStub>();

var mauiApp =
builder.ConfigureMauiHandlers(collection =>
{
handlersCalled = true;

Assert.Throws<InvalidOperationException>(() =>
collection.AddCompatibilityRenderer(typeof(ButtonHandlerStub), typeof(Object))
);
})
.Build();

_ = mauiApp.Services.GetRequiredService<IMauiHandlersFactory>();
Assert.True(handlersCalled);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
<AndroidEnvironment Condition="'$(IsEmulator)' != 'true'" Include="Platforms\Android\environment.device.txt" />
</ItemGroup>

<ItemGroup Condition=" '$(UseMaui)' != 'true' ">
<ProjectReference Include="..\..\..\Compatibility\Core\src\Compatibility.csproj" />
<ItemGroup Condition=" '$(UseMaui)' != 'true' ">
<ProjectReference Include="..\..\..\Core\src\Core.csproj" />
<ProjectReference Include="..\..\src\Xaml\Controls.Xaml.csproj" />
<ProjectReference Include="..\..\src\Core\Controls.Core.csproj" />
Expand Down
Loading

0 comments on commit 474d332

Please sign in to comment.