-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from mhutch/more-tfms
Add more known legacy TFMs
- Loading branch information
Showing
8 changed files
with
409 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using MonoDevelop.MSBuild.Schema; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace MonoDevelop.MSBuild.Tests; | ||
|
||
[TestFixture] | ||
class FrameworkInfoTests | ||
{ | ||
[TestCase ("net48")] | ||
[TestCase ("net4.8")] | ||
[TestCase ("sl3")] | ||
[TestCase ("wp8")] | ||
[TestCase ("uap10.0.1234")] | ||
[TestCase ("uap10.0")] | ||
[TestCase ("net8.0-android")] | ||
[TestCase ("net8.0")] | ||
public void ValidFrameworkName (string name) | ||
{ | ||
var validationResult = FrameworkInfoProvider.Instance.ValidateFrameworkShortName (name, out _, out _, out _, out _, out _); | ||
Assert.AreEqual (FrameworkNameValidationResult.OK, validationResult); | ||
} | ||
|
||
[TestCase ("foo")] | ||
[TestCase ("foo1.0")] | ||
public void UnknownIdentifier (string name) | ||
{ | ||
var validationResult = FrameworkInfoProvider.Instance.ValidateFrameworkShortName (name, out _, out _, out _, out _, out _); | ||
Assert.AreEqual (FrameworkNameValidationResult.UnknownIdentifier, validationResult); | ||
} | ||
|
||
[TestCase ("net485")] | ||
[TestCase ("sl6.0")] | ||
public void UnknownVersion (string name) | ||
{ | ||
var validationResult = FrameworkInfoProvider.Instance.ValidateFrameworkShortName (name, out _, out _, out _, out _, out _); | ||
Assert.AreEqual (FrameworkNameValidationResult.UnknownVersion, validationResult); | ||
} | ||
|
||
[TestCase ("net481-client")] | ||
[TestCase ("net35-bad")] | ||
public void UnknownProfile (string name) | ||
{ | ||
var validationResult = FrameworkInfoProvider.Instance.ValidateFrameworkShortName (name, out _, out _, out _, out _, out _); | ||
Assert.AreEqual (FrameworkNameValidationResult.UnknownProfile, validationResult); | ||
} | ||
|
||
[TestCase ("net6.0-fridge")] | ||
public void UnknownPlatform (string name) | ||
{ | ||
var validationResult = FrameworkInfoProvider.Instance.ValidateFrameworkShortName (name, out _, out _, out _, out _, out _); | ||
Assert.AreEqual (FrameworkNameValidationResult.UnknownPlatform, validationResult); | ||
} | ||
|
||
[TestCase ("net481", ".NET Framework 4.8.1")] | ||
[TestCase ("net4.8.1", ".NET Framework 4.8.1")] | ||
[TestCase ("wpa81", "Windows Phone (UWP) 8.1")] | ||
[TestCase ("net6.0-android9000.0", ".NET 6.0 with platform-specific APIs for Android 9000.0")] | ||
[TestCase ("net6.0-android", ".NET 6.0 with platform-specific APIs for Android 31.0")] | ||
[TestCase ("net6.0-android32.0", ".NET 6.0 with platform-specific APIs for Android 32.0")] | ||
[TestCase ("net7.0-android", ".NET 7.0 with platform-specific APIs for Android 33.0")] | ||
[TestCase ("net6.0", ".NET 6.0")] | ||
public void FrameworkDescription (string tfm, string description) | ||
{ | ||
var fx = FrameworkInfoProvider.TryGetFrameworkInfo (tfm); | ||
Assert.IsNotNull (fx); | ||
|
||
var actualDescription = FrameworkInfoProvider.GetDisplayDescription (fx.Reference); | ||
Assert.AreEqual (description, actualDescription); | ||
} | ||
|
||
[TestCase ("net481", ".NETFramework,Version=v4.8.1")] | ||
[TestCase ("net4.8.1", ".NETFramework,Version=v4.8.1")] | ||
[TestCase ("wpa81", "WindowsPhoneApp,Version=v8.1")] | ||
[TestCase ("net6.0-android9000.0", ".NETCoreApp,Version=v6.0 | Android 9000.0")] | ||
[TestCase ("net6.0-android", ".NETCoreApp,Version=v6.0 | Android 31.0")] | ||
[TestCase ("net6.0-android32.0", ".NETCoreApp,Version=v6.0 | Android 32.0")] | ||
[TestCase ("net7.0-android", ".NETCoreApp,Version=v7.0 | Android 33.0")] | ||
[TestCase ("net6.0", ".NETCoreApp,Version=v6.0")] | ||
public void FrameworkTitle (string tfm, string description) | ||
{ | ||
var fx = FrameworkInfoProvider.TryGetFrameworkInfo (tfm); | ||
Assert.IsNotNull (fx); | ||
|
||
var actualDescription = FrameworkInfoProvider.GetDisplayTitle (fx.Reference); | ||
Assert.AreEqual (description, actualDescription); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
MonoDevelop.MSBuild/Schema/FrameworkInfoProvider.PlatformId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
#nullable enable | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace MonoDevelop.MSBuild.Schema | ||
{ | ||
partial class FrameworkInfoProvider | ||
{ | ||
static class KnownPlatform | ||
{ | ||
public const string Windows = "Windows"; | ||
public const string Android = "Android"; | ||
public const string iOS = "iOS"; | ||
public const string macOS = "macOS"; | ||
public const string tvOS = "tvOS"; | ||
public const string MacCatalyst = "MacCatalyst"; | ||
public const string Tizen = "Tizen"; | ||
public const string Browser = "Browser"; | ||
|
||
static class LowerId | ||
{ | ||
public const string Windows = "windows"; | ||
public const string Android = "android"; | ||
public const string iOS = "ios"; | ||
public const string macOS = "macos"; | ||
public const string tvOS = "tvos"; | ||
public const string MacCatalyst = "maccatalyst"; | ||
public const string Tizen = "tizen"; | ||
public const string Browser = "browser"; | ||
} | ||
|
||
public static string ToLowerCase (string platform) => platform switch { | ||
Windows => LowerId.Windows, | ||
Android => LowerId.Android, | ||
iOS => LowerId.iOS, | ||
macOS => LowerId.macOS, | ||
tvOS => LowerId.tvOS, | ||
MacCatalyst => LowerId.MacCatalyst, | ||
Tizen => LowerId.Tizen, | ||
Browser => LowerId.Browser, | ||
_ => platform.ToLowerInvariant () | ||
}; | ||
|
||
public static string ToCanonicalCase (string platform) | ||
{ | ||
return CanonicalCaseFromLower (platform) | ||
?? CanonicalCaseFromLower (platform.ToLowerInvariant ()) | ||
?? platform; | ||
|
||
static string? CanonicalCaseFromLower (string platform) => platform switch { | ||
LowerId.Windows => Windows, | ||
LowerId.Android => Android, | ||
LowerId.iOS => iOS, | ||
LowerId.macOS => macOS, | ||
LowerId.tvOS => tvOS, | ||
LowerId.MacCatalyst => MacCatalyst, | ||
LowerId.Tizen => Tizen, | ||
LowerId.Browser => Browser, | ||
_ => null | ||
}; | ||
} | ||
|
||
public static bool TryGetDefaultPlatformVersion (int netcoreappMajorVersion, string platform, [NotNullWhen (true)] out Version? defaultPlatformVersion) | ||
{ | ||
return defaultPlatformVersions.TryGetValue ((netcoreappMajorVersion, ToLowerCase (platform)), out defaultPlatformVersion); | ||
} | ||
|
||
static readonly Dictionary<(int, string), Version> defaultPlatformVersions = new () { | ||
{ (6, LowerId.Android), new Version (31, 0) }, | ||
{ (7, LowerId.Android), new Version (33, 0) }, | ||
{ (8, LowerId.Android), new Version (34, 0) }, | ||
{ (6, LowerId.iOS), new Version (15, 0) }, | ||
{ (7, LowerId.iOS), new Version (16, 1) }, | ||
{ (8, LowerId.iOS), new Version (17, 2) }, | ||
{ (5, LowerId.MacCatalyst), new Version (15, 0) }, | ||
{ (7, LowerId.MacCatalyst), new Version (16, 1) }, | ||
{ (8, LowerId.MacCatalyst), new Version (17, 2) }, | ||
{ (6, LowerId.macOS), new Version (12, 0) }, | ||
{ (7, LowerId.macOS), new Version (13, 0) }, | ||
{ (8, LowerId.macOS), new Version (14, 2) }, | ||
{ (6, LowerId.tvOS), new Version (15, 1) }, | ||
{ (7, LowerId.tvOS), new Version (16, 1) }, | ||
{ (8, LowerId.tvOS), new Version (17, 1) }, | ||
{ (7, LowerId.Tizen), new Version (7, 0) }, | ||
{ (8, LowerId.Tizen), new Version (8, 0) }, | ||
{ (6, LowerId.Windows), new Version (7, 0) }, | ||
{ (7, LowerId.Windows), new Version (7, 0) }, | ||
{ (8, LowerId.Windows), new Version (7, 0) }, | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.