Skip to content

Commit c0239ab

Browse files
authored
Merge pull request #8875 from NuGet/dev
[ReleasePrep][2021.11.10]RI of dev into main
2 parents 0be284e + 2d9bd91 commit c0239ab

23 files changed

Lines changed: 393 additions & 27 deletions

src/AccountDeleter/EmptyFeatureFlagService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public bool IsDisplayPackagePageV2PreviewEnabled(User user)
8181
throw new NotImplementedException();
8282
}
8383

84+
public bool IsDisplayTargetFrameworkEnabled()
85+
{
86+
throw new NotImplementedException();
87+
}
88+
8489
public bool IsDisplayVulnerabilitiesEnabled()
8590
{
8691
throw new NotImplementedException();

src/DatabaseMigrationTools/DatabaseMigrationTools.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<PrivateAssets>all</PrivateAssets>
6666
</PackageReference>
6767
<PackageReference Include="NuGet.Services.Validation">
68-
<Version>2.90.0</Version>
68+
<Version>2.91.0</Version>
6969
</PackageReference>
7070
</ItemGroup>
7171
<ItemGroup>

src/GitHubVulnerabilities2Db/Fakes/FakeFeatureFlagService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,10 @@ public bool IsDisplayPackagePageV2PreviewEnabled(User user)
269269
{
270270
throw new NotImplementedException();
271271
}
272+
273+
public bool IsDisplayTargetFrameworkEnabled()
274+
{
275+
throw new NotImplementedException();
276+
}
272277
}
273278
}

src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<Version>4.3.0-dev-5066115</Version>
9292
</PackageReference>
9393
<PackageReference Include="NuGet.Services.Cursor">
94-
<Version>2.90.0</Version>
94+
<Version>2.91.0</Version>
9595
</PackageReference>
9696
</ItemGroup>
9797
<ItemGroup>

src/NuGet.Services.Entities/NuGet.Services.Entities.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<Version>10.0.3</Version>
1616
</PackageReference>
1717
<PackageReference Include="NuGet.Frameworks">
18-
<Version>5.9.0</Version>
18+
<Version>6.0.0</Version>
1919
</PackageReference>
2020
</ItemGroup>
2121

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using NuGet.Frameworks;
7+
8+
namespace NuGetGallery.Frameworks
9+
{
10+
public class FrameworkCompatibilityService : IFrameworkCompatibilityService
11+
{
12+
private static readonly IFrameworkCompatibilityProvider CompatibilityProvider = DefaultCompatibilityProvider.Instance;
13+
private static readonly IReadOnlyList<NuGetFramework> AllSupportedFrameworks = SupportedFrameworks.AllSupportedNuGetFrameworks;
14+
private static readonly IReadOnlyDictionary<NuGetFramework, ISet<NuGetFramework>> CompatibilityMatrix = GetCompatibilityMatrix();
15+
16+
public ISet<NuGetFramework> GetCompatibleFrameworks(IEnumerable<NuGetFramework> packageFrameworks)
17+
{
18+
if (packageFrameworks == null)
19+
{
20+
throw new ArgumentNullException(nameof(packageFrameworks));
21+
}
22+
23+
var allCompatibleFrameworks = new HashSet<NuGetFramework>();
24+
25+
foreach (var packageFramework in packageFrameworks)
26+
{
27+
if (packageFrameworks == null || packageFramework.IsUnsupported || packageFramework.IsPCL)
28+
{
29+
continue;
30+
}
31+
32+
if (CompatibilityMatrix.TryGetValue(packageFramework, out var compatibleFrameworks))
33+
{
34+
allCompatibleFrameworks.UnionWith(compatibleFrameworks);
35+
}
36+
}
37+
38+
return allCompatibleFrameworks;
39+
}
40+
41+
private static IReadOnlyDictionary<NuGetFramework, ISet<NuGetFramework>> GetCompatibilityMatrix()
42+
{
43+
var matrix = new Dictionary<NuGetFramework, ISet<NuGetFramework>>();
44+
45+
foreach (var packageFramework in AllSupportedFrameworks)
46+
{
47+
var compatibleFrameworks = new HashSet<NuGetFramework>();
48+
matrix.Add(packageFramework, compatibleFrameworks);
49+
50+
foreach (var projectFramework in AllSupportedFrameworks)
51+
{
52+
// This compatibility check is to know if the packageFramework can be installed on a certain projectFramework
53+
if (CompatibilityProvider.IsCompatible(projectFramework, packageFramework))
54+
{
55+
compatibleFrameworks.Add(projectFramework);
56+
}
57+
}
58+
}
59+
60+
return matrix;
61+
}
62+
}
63+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.Collections.Generic;
5+
using NuGet.Frameworks;
6+
7+
namespace NuGetGallery.Frameworks
8+
{
9+
public interface IFrameworkCompatibilityService
10+
{
11+
/// <summary>
12+
/// Computes a set of compatible target frameworks from a list of target frameworks.
13+
/// </summary>
14+
/// <param name="frameworks">List of frameworks.</param>
15+
/// <returns>A set of computed compatible target frameworks.</returns>
16+
/// <remarks>
17+
/// Every element on the returned set is compatible with at least one of the target frameworks from the input.
18+
/// </remarks>
19+
ISet<NuGetFramework> GetCompatibleFrameworks(IEnumerable<NuGetFramework> frameworks);
20+
}
21+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using NuGet.Frameworks;
7+
using static NuGet.Frameworks.FrameworkConstants;
8+
using static NuGet.Frameworks.FrameworkConstants.CommonFrameworks;
9+
10+
namespace NuGetGallery.Frameworks
11+
{
12+
/// <summary>
13+
/// This class contains documented supported frameworks.
14+
/// </summary>
15+
/// <remarks>
16+
/// All these frameworks were retrieved from the following sources:
17+
/// dotnet documentation: https://docs.microsoft.com/en-us/dotnet/standard/frameworks.
18+
/// nuget documentation: https://docs.microsoft.com/en-us/nuget/reference/target-frameworks.
19+
/// nuget client FrameworkConstants.CommonFrameworks: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Frameworks/FrameworkConstants.cs.
20+
/// </remarks>
21+
public static class SupportedFrameworks
22+
{
23+
public static readonly NuGetFramework MonoAndroid = new NuGetFramework(FrameworkIdentifiers.MonoAndroid, EmptyVersion);
24+
public static readonly NuGetFramework MonoTouch = new NuGetFramework(FrameworkIdentifiers.MonoTouch, EmptyVersion);
25+
public static readonly NuGetFramework MonoMac = new NuGetFramework(FrameworkIdentifiers.MonoMac, EmptyVersion);
26+
public static readonly NuGetFramework Net48 = new NuGetFramework(FrameworkIdentifiers.Net, new Version(4, 8, 0, 0));
27+
public static readonly NuGetFramework Net50Windows = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version5, "windows");
28+
public static readonly NuGetFramework Net60Android = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "android");
29+
public static readonly NuGetFramework Net60Ios = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "ios");
30+
public static readonly NuGetFramework Net60MacOs = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "macos");
31+
public static readonly NuGetFramework Net60MacCatalyst = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "maccatalyst");
32+
public static readonly NuGetFramework Net60Tizen = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "tizen");
33+
public static readonly NuGetFramework Net60TvOs = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "tvos");
34+
public static readonly NuGetFramework Net60Windows = new NuGetFramework(FrameworkIdentifiers.NetCoreApp, Version6, "windows");
35+
public static readonly NuGetFramework NetCore = new NuGetFramework(FrameworkIdentifiers.NetCore, EmptyVersion);
36+
public static readonly NuGetFramework NetMf = new NuGetFramework(FrameworkIdentifiers.NetMicro, EmptyVersion);
37+
public static readonly NuGetFramework UAP = new NuGetFramework(FrameworkIdentifiers.UAP, EmptyVersion);
38+
public static readonly NuGetFramework Win = new NuGetFramework(FrameworkIdentifiers.Windows, EmptyVersion);
39+
public static readonly NuGetFramework WinRt = new NuGetFramework(FrameworkIdentifiers.WinRT, EmptyVersion);
40+
public static readonly NuGetFramework WP = new NuGetFramework(FrameworkIdentifiers.WindowsPhone, EmptyVersion);
41+
public static readonly NuGetFramework XamarinIOs = new NuGetFramework(FrameworkIdentifiers.XamarinIOs, EmptyVersion);
42+
public static readonly NuGetFramework XamarinMac = new NuGetFramework(FrameworkIdentifiers.XamarinMac, EmptyVersion);
43+
public static readonly NuGetFramework XamarinPlaystation3 = new NuGetFramework(FrameworkIdentifiers.XamarinPlayStation3, EmptyVersion);
44+
public static readonly NuGetFramework XamarinPlayStation4 = new NuGetFramework(FrameworkIdentifiers.XamarinPlayStation4, EmptyVersion);
45+
public static readonly NuGetFramework XamarinPlayStationVita = new NuGetFramework(FrameworkIdentifiers.XamarinPlayStationVita, EmptyVersion);
46+
public static readonly NuGetFramework XamarinTvOs = new NuGetFramework(FrameworkIdentifiers.XamarinTVOS, EmptyVersion);
47+
public static readonly NuGetFramework XamarinWatchOs = new NuGetFramework(FrameworkIdentifiers.XamarinWatchOS, EmptyVersion);
48+
public static readonly NuGetFramework XamarinXbox360 = new NuGetFramework(FrameworkIdentifiers.XamarinXbox360, EmptyVersion);
49+
public static readonly NuGetFramework XamarinXboxOne = new NuGetFramework(FrameworkIdentifiers.XamarinXboxOne, EmptyVersion);
50+
51+
public static readonly IReadOnlyList<NuGetFramework> AllSupportedNuGetFrameworks;
52+
53+
static SupportedFrameworks()
54+
{
55+
AllSupportedNuGetFrameworks = new List<NuGetFramework>
56+
{
57+
AspNet, AspNet50, AspNetCore, AspNetCore50,
58+
Dnx, Dnx45, Dnx451, Dnx452, DnxCore, DnxCore50,
59+
DotNet, DotNet50, DotNet51, DotNet52, DotNet53, DotNet54, DotNet55, DotNet56,
60+
MonoAndroid, MonoMac, MonoTouch,
61+
Native,
62+
Net11, Net2, Net35, Net4, Net403, Net45, Net451, Net452, Net46, Net461, Net462, Net463, Net47, Net471, Net472, Net48,
63+
Net50, Net50Windows, Net60, Net60Android, Net60Ios, Net60MacCatalyst, Net60MacOs, Net60TvOs, Net60Windows,
64+
NetCore, NetCore45, NetCore451, NetCore50,
65+
NetCoreApp10, NetCoreApp11, NetCoreApp20, NetCoreApp21, NetCoreApp22, NetCoreApp30, NetCoreApp31,
66+
NetMf,
67+
NetStandard, NetStandard10, NetStandard11, NetStandard12, NetStandard13, NetStandard14, NetStandard15, NetStandard16, NetStandard17, NetStandard20, NetStandard21,
68+
NetStandardApp15,
69+
SL4, SL5,
70+
Tizen3, Tizen4, Tizen6,
71+
UAP, UAP10,
72+
Win, Win8, Win81, Win10,
73+
WinRt,
74+
WP, WP7, WP75, WP8, WP81, WPA81,
75+
XamarinIOs, XamarinMac, XamarinPlaystation3, XamarinPlayStation4, XamarinPlayStationVita, XamarinTvOs, XamarinWatchOs, XamarinXbox360, XamarinXboxOne
76+
};
77+
}
78+
}
79+
}

src/NuGetGallery.Core/NuGetGallery.Core.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<Version>5.9.0</Version>
5151
</PackageReference>
5252
<PackageReference Include="NuGet.Services.FeatureFlags">
53-
<Version>2.90.0</Version>
53+
<Version>2.91.0</Version>
5454
</PackageReference>
5555
<PackageReference Include="WindowsAzure.Storage">
5656
<Version>9.3.3</Version>
@@ -59,13 +59,13 @@
5959

6060
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
6161
<PackageReference Include="NuGet.Services.Messaging.Email">
62-
<Version>2.90.0</Version>
62+
<Version>2.91.0</Version>
6363
</PackageReference>
6464
<PackageReference Include="NuGet.Services.Validation">
65-
<Version>2.90.0</Version>
65+
<Version>2.91.0</Version>
6666
</PackageReference>
6767
<PackageReference Include="NuGet.Services.Validation.Issues">
68-
<Version>2.90.0</Version>
68+
<Version>2.91.0</Version>
6969
</PackageReference>
7070
<PackageReference Include="NuGet.StrongName.elmah.corelibrary">
7171
<Version>1.2.2</Version>

src/NuGetGallery.Services/Configuration/ConfigurationService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class ConfigurationService : IGalleryConfigurationService, IConfiguration
3939
SettingPrefix + "SupportRequestSqlServer",
4040
SettingPrefix + "ValidationSqlServer" };
4141

42-
public ISecretInjector SecretInjector { get; set; }
42+
public ICachingSecretInjector SecretInjector { get; set; }
4343

4444
/// <summary>
4545
/// Initializes the configuration service and associates a secret injector based on the configured KeyVault
@@ -52,7 +52,7 @@ public static ConfigurationService Initialize()
5252
var secretReader = secretReaderFactory.CreateSecretReader();
5353
var secretInjector = secretReaderFactory.CreateSecretInjector(secretReader);
5454

55-
configuration.SecretInjector = secretInjector;
55+
configuration.SecretInjector = secretInjector as ICachingSecretInjector ?? throw new InvalidOperationException("Caching secret reader is required to run the service");
5656

5757
return configuration;
5858
}

0 commit comments

Comments
 (0)