diff --git a/README.md b/README.md index 1121dcb98..bd63e98ed 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,26 @@ The above example would transform all occurrences of `Windows.UI.WindowManagemen Since the Upgrade Assistant uses Roslyn to parse and manipulate user-code, even user-code that calls `AppWindow.TryCreate()` will be upgraded. +For XAML upgrades additional mappings are needed. Here is an example: +```json +{ + "http://xamarin.com/schemas/2020/toolkit": { + "value": "http://schemas.microsoft.com/dotnet/2022/maui/toolkit", + "kind": "xmlnamespace", + "state": "Replaced", + "properties": [ + "Xamarin.CommunityToolkit.Behaviors", + "Xamarin.CommunityToolkit.Converters", + "Xamarin.CommunityToolkit.UI.Views" + ] + } +} +``` + +Upgrade Assistant will update XML namespaces like `xmlns:toolkit="http://xamarin.com/schemas/2020/toolkit"` to `xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"`. +The `properties` contain values from assembly level XmlnsDefinitionAttribute from old SDK. Those values will be used to update +xmlns values like `xmlns:tk='clr-namespace:Xamarin.CommunityToolkit.Behaviors; assembly=...'` to `xmlns:tk='clr-namespace:Microsoft.Maui.Behaviors; assembly=...'`. + ## Engage, Contribute and Give Feedback Some of the best ways to contribute are to use the tool to upgrade your apps to the latest version of .NET (STS, LTS, or preview), file issues for feature-requests or bugs, join in design conversations, and make pull-requests. diff --git a/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/XamarinCommunityToolkit.apimap.json b/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/XamarinCommunityToolkit.apimap.json new file mode 100644 index 000000000..53d4fd688 --- /dev/null +++ b/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/XamarinCommunityToolkit.apimap.json @@ -0,0 +1,76 @@ +{ + "Xamarin.CommunityToolkit.Behaviors": { + "value": "CommunityToolkit.Maui.Behaviors;CommunityToolkit.Maui.Animations", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Behaviors.Internals": { + "value": "CommunityToolkit.Maui.Behaviors", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Converters": { + "value": "CommunityToolkit.Maui.Converters", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Core": { + "value": "CommunityToolkit.Maui.Core", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Effects": { + "value": "CommunityToolkit.Maui.Core", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Extensions": { + "value": "CommunityToolkit.Maui.Extensions", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Extensions.Internals": { + "value": "CommunityToolkit.Maui.Extensions", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Helpers": { + "value": "CommunityToolkit.Maui.Converters", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.UI.Views": { + "value": "CommunityToolkit.Maui.Views;CommunityToolkit.Maui.Layouts;CommunityToolkit.Maui.Core;CommunityToolkit.Maui;CommunityToolkit.Maui.ImageSources;CommunityToolkit.Maui.Converters", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Markup": { + "value": "CommunityToolkit.Maui.Markup", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Markup.LeftToRight": { + "value": "CommunityToolkit.Maui.Markup", + "kind": "namespace", + "state": "Replaced" + }, + "Xamarin.CommunityToolkit.Markup.RightToLeft": { + "value": "CommunityToolkit.Maui.Markup", + "kind": "namespace", + "state": "Replaced" + }, + "http://xamarin.com/schemas/2020/toolkit": { + "value": "http://schemas.microsoft.com/dotnet/2022/maui/toolkit", + "kind": "xmlnamespace", + "state": "Replaced", + "properties": { + "xmlnsdefinitions": [ + "Xamarin.CommunityToolkit.Behaviors", + "Xamarin.CommunityToolkit.Converters", + "Xamarin.CommunityToolkit.Effects", + "Xamarin.CommunityToolkit.Extensions", + "Xamarin.CommunityToolkit.UI.Views" + ] + } + } +} \ No newline at end of file diff --git a/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/XamarinCommunityToolkit.packagemap.json b/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/XamarinCommunityToolkit.packagemap.json new file mode 100644 index 000000000..853f2a1f5 --- /dev/null +++ b/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/XamarinCommunityToolkit.packagemap.json @@ -0,0 +1,33 @@ +{ + "packages": [ + { + "name": "Xamarin.CommunityToolkit", + "frameworks": { + ".NETCoreApp,Version=v6.0": [ + { + "name": "CommunityToolkit.Maui", + "version": "2.*" + } + ], + ".NETCoreApp,Version=v7.0": [ + { + "name": "CommunityToolkit.Maui", + "version": "5.*" + } + ], + ".NETCoreApp,Version=v8.0": [ + { + "name": "CommunityToolkit.Maui", + "version": "5.*" + } + ], + ".NETCoreApp,Version=v9.0": [ + { + "name": "CommunityToolkit.Maui", + "prerelease": true + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/metadata.json b/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/metadata.json new file mode 100644 index 000000000..9f075dbea --- /dev/null +++ b/src/UpgradeAssistant.Mappings/mappings/Microsoft/CommunityToolkit/metadata.json @@ -0,0 +1,4 @@ +{ + "traits": "(Xamarin | Maui)", + "order": 1000 +} diff --git a/tests/UpgradeAssistant.Mappings.Tests/ApiMapValidationTests.cs b/tests/UpgradeAssistant.Mappings.Tests/ApiMapValidationTests.cs index 8d82a170e..411ea4540 100644 --- a/tests/UpgradeAssistant.Mappings.Tests/ApiMapValidationTests.cs +++ b/tests/UpgradeAssistant.Mappings.Tests/ApiMapValidationTests.cs @@ -9,7 +9,7 @@ namespace Microsoft.UpgradeAssistant.Mappings.Tests; public partial class ValidationTests { - private static readonly string[] Kinds = new string[] { "property", "method", "namespace", "type" }; + private static readonly string[] Kinds = new string[] { "property", "method", "namespace", "type", "xmlnamespace" }; private static readonly string[] States = new string[] { "NotImplemented", "Removed", "Replaced" }; [TestMethod] diff --git a/tests/UpgradeAssistant.Mappings.Tests/SchemaValidationTests.cs b/tests/UpgradeAssistant.Mappings.Tests/SchemaValidationTests.cs index b4364dd69..7aafbe96a 100644 --- a/tests/UpgradeAssistant.Mappings.Tests/SchemaValidationTests.cs +++ b/tests/UpgradeAssistant.Mappings.Tests/SchemaValidationTests.cs @@ -244,6 +244,10 @@ private static void AssertApiMapEntry(string relativePath, string elementPath, J { AssertPropertyType(relativePath, elementPath, property, JsonValueKind.String); } + else if (property.NameEquals("properties")) + { + AssertPropertyType(relativePath, elementPath, property, JsonValueKind.Object); + } else { AssertUnknownProperty(relativePath, elementPath, property);