diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs index ebc19cd548b..03a49e70c87 100644 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs +++ b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs @@ -26,30 +26,52 @@ internal enum TypePresenceIndicator private static Dictionary>> _differencesDictionary = null; + /* + * SDK vs API Version + * 10240 1.0.0.0 + * 10586 2.0.0.0 + * 14393 3.0.0.0 + * 15063 4.0.0.0 + * 16299 5.0.0.0 + * 17134 6.0.0.0 + * 17763 7.0.0.0 + * 18362 8.0.0.0 + */ + /// - /// Embedded differences between API contract version 4 and 5. + /// Embedded differences between API contract version 5 and 6. /// - public const string N1DifferencesRes = "Differences-5.0.0.0.gz"; + public const string N2DifferencesRes = "Differences-6.0.0.0.gz"; /// - /// Embedded differences between API contract version 5 and 6. + /// Embedded differences between API contract version 6 and 7. /// - public const string N0DifferencesRes = "Differences-6.0.0.0.gz"; + public const string N1DifferencesRes = "Differences-7.0.0.0.gz"; + + /// + /// Embedded differences between API contract version 7 and 8. + /// + public const string N0DifferencesRes = "Differences-8.0.0.0.gz"; /// /// Earliest supported SDK version. /// - public const string N2SDKVersion = "15063"; + public const string BaseSDKVersion = "16299"; + + /// + /// Earliest supported SDK version. + /// + public const string N2SDKVersion = "17134"; /// /// Intermediate SDK version. /// - public const string N1SDKVersion = "16299"; + public const string N1SDKVersion = "17763"; /// /// Latest SDK version. /// - public const string N0SDKVersion = "17134"; + public const string N0SDKVersion = "18362"; /// /// Platform related diagnostic descriptor @@ -161,7 +183,7 @@ public static Platform GetPlatformForSymbol(ISymbol symbol) // Any call to ApiInformation.* is allowed without warning if (symbol.ContainingType?.Name == "ApiInformation") { - return new Platform(PlatformKind.Uwp, Analyzer.N2SDKVersion); + return new Platform(PlatformKind.Uwp, Analyzer.BaseSDKVersion); } // Don't want to give warning when analyzing code in an PCL project. @@ -174,13 +196,13 @@ public static Platform GetPlatformForSymbol(ISymbol symbol) // Some WinRT types like Windows.UI.Color get projected to come from .NET assemblies, always present: if (assembly.StartsWith("System.Runtime.")) { - return new Platform(PlatformKind.Uwp, Analyzer.N2SDKVersion); + return new Platform(PlatformKind.Uwp, Analyzer.BaseSDKVersion); } // Some things are emphatically part of UWP.10240 if (assembly == "Windows.Foundation.FoundationContract" || (assembly == "Windows.Foundation.UniversalApiContract" && version == 1)) { - return new Platform(PlatformKind.Uwp, Analyzer.N2SDKVersion); + return new Platform(PlatformKind.Uwp, Analyzer.BaseSDKVersion); } if (assembly == "Windows.Foundation.UniversalApiContract") @@ -189,38 +211,28 @@ public static Platform GetPlatformForSymbol(ISymbol symbol) var typeName = isType ? symbol.ToDisplayString() : symbol.ContainingType.ToDisplayString(); - TypePresenceIndicator presentInN0ApiDiff = CheckCollectionForType(Analyzer.GetUniversalApiAdditions(Analyzer.N0DifferencesRes), typeName, symbol); + var platformN0 = GetPlatformFromDifferences(symbol, typeName, N0DifferencesRes, N0SDKVersion); - if (presentInN0ApiDiff == TypePresenceIndicator.New) + if (!string.IsNullOrEmpty(platformN0.Version)) { - // the entire type was found in Target Version - return new Platform(PlatformKind.Uwp, Analyzer.N0SDKVersion); + return platformN0; } - else if (presentInN0ApiDiff == TypePresenceIndicator.Changes) + + var platformN1 = GetPlatformFromDifferences(symbol, typeName, N1DifferencesRes, N1SDKVersion); + + if (!string.IsNullOrEmpty(platformN1.Version)) { - // the entire type was found in Target Version with matching parameter lengths - return new Platform(PlatformKind.Uwp, Analyzer.N0SDKVersion, true); + return platformN1; } - else - { - TypePresenceIndicator presentInN1ApiDiff = CheckCollectionForType(Analyzer.GetUniversalApiAdditions(Analyzer.N1DifferencesRes), typeName, symbol); - if (presentInN1ApiDiff == TypePresenceIndicator.New) - { - // the entire type was found in Target Version - return new Platform(PlatformKind.Uwp, Analyzer.N1SDKVersion); - } - else if (presentInN1ApiDiff == TypePresenceIndicator.Changes) - { - // the entire type was found in Target Version with matching parameter lengths - return new Platform(PlatformKind.Uwp, Analyzer.N1SDKVersion, true); - } - else - { - // the type was in Min version - return new Platform(PlatformKind.Uwp, Analyzer.N2SDKVersion); - } + var platformN2 = GetPlatformFromDifferences(symbol, typeName, N2DifferencesRes, N2SDKVersion); + + if (!string.IsNullOrEmpty(platformN2.Version)) + { + return platformN2; } + + return new Platform(PlatformKind.Uwp, Analyzer.BaseSDKVersion); } // All other Windows.* types come from platform-specific extensions @@ -232,6 +244,27 @@ public static Platform GetPlatformForSymbol(ISymbol symbol) } } + private static Platform GetPlatformFromDifferences(ISymbol symbol, string typeName, string differencesRes, string sdkVersion) + { + TypePresenceIndicator presentInApiDiff = CheckCollectionForType(GetUniversalApiAdditions(differencesRes), typeName, symbol); + + if (presentInApiDiff == TypePresenceIndicator.New) + { + // the entire type was found in Target Version + return new Platform(PlatformKind.Uwp, sdkVersion); + } + else if (presentInApiDiff == TypePresenceIndicator.Changes) + { + // the entire type was found in Target Version with matching parameter lengths + return new Platform(PlatformKind.Uwp, sdkVersion, true); + } + else + { + // the type was in Min version + return new Platform(PlatformKind.Uwp); + } + } + /// /// returns instance of for /// diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Differences-8.0.0.0.gz b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Differences-8.0.0.0.gz new file mode 100644 index 00000000000..0d81d3cb0d9 Binary files /dev/null and b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Differences-8.0.0.0.gz differ diff --git a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj index bdd4be0b424..88a48314641 100644 --- a/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj +++ b/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer.csproj @@ -15,11 +15,13 @@ + +