Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mapping for Xamarin.CommunityToolkit #1586

Merged
merged 4 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"traits": "(Xamarin | Maui)",
"order": 1000
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down