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

Update TFMs #4394

Merged
merged 6 commits into from
Sep 13, 2023
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
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<LatestTargetFramework>$(TargetFrameworkName)$(TargetFrameworkVersion)</LatestTargetFramework>
<!-- All the .NET TFMs we're building -->
<SupportedNetCoreTargetFrameworks>$(LatestTargetFramework)</SupportedNetCoreTargetFrameworks>
<NetCoreTargetFrameworks>$(SupportedNetCoreTargetFrameworks);netcoreapp3.1</NetCoreTargetFrameworks>
<NetCoreTargetFrameworks>$(SupportedNetCoreTargetFrameworks);net6.0</NetCoreTargetFrameworks>

<!-- The minimum supported .NET version for external consumers. This is used for packaging control, see Packaging.targets -->
<MinimumSupportedTfmForPackaging>$(LatestTargetFramework)</MinimumSupportedTfmForPackaging>
<MinimumSupportedTfmForPackaging>net6.0</MinimumSupportedTfmForPackaging>

<!-- Limit the .NET TFMs when .targetframeworks is defined -->
<!--
Expand All @@ -27,12 +27,12 @@
<CustomTargetFrameworks Condition="Exists('$(MSBuildThisFileDirectory)\.targetframeworks')">$([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)\.targetframeworks').Trim())</CustomTargetFrameworks>
<SupportedNetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' != ''">$(LatestTargetFramework)</SupportedNetCoreTargetFrameworks>
<NetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' != ''">$(SupportedNetCoreTargetFrameworks)</NetCoreTargetFrameworks>
<NetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' != '' AND $(CustomTargetFrameworks.Contains('netcoreapp3.1'))">$(NetCoreTargetFrameworks);netcoreapp3.1</NetCoreTargetFrameworks>
<NetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' != '' AND $(CustomTargetFrameworks.Contains('net6.0'))">$(NetCoreTargetFrameworks);net6.0</NetCoreTargetFrameworks>
<ConditionalNet462 Condition="'$(CustomTargetFrameworks)' == '' OR $(CustomTargetFrameworks.Contains('net462'))">;net462</ConditionalNet462>

<!-- All the .NET TFMs we're testing against -->
<TestNetCoreTargetFrameworks>$(NetCoreTargetFrameworks)</TestNetCoreTargetFrameworks>
<TestNetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' == ''">$(TestNetCoreTargetFrameworks);net7.0;net6.0</TestNetCoreTargetFrameworks>
<TestNetCoreTargetFrameworks Condition="'$(CustomTargetFrameworks)' == ''">$(TestNetCoreTargetFrameworks);net6.0</TestNetCoreTargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RussKie now this emits a warning that looks like:

Error occurred while restoring NuGet packages: Invalid restore input. The original target frameworks value must match the aliases. Original target frameworks: net8.0;net6.0;net6.0;net462, aliases: net8.0;net6.0;net462. Input files: C:\Users\...\source\dotnet-ext\test\Generators\Microsoft.Gen.AutoClient\Generated\Microsoft.Gen.AutoClient

I.e., the net6.0 TFM is listed twice for test projects that have <TargetFrameworks>$(TestNetCoreTargetFrameworks)</TargetFrameworks>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can either you or @RussKie log an issue to fix this so that we make sure it is fixed? How come we aren't seeing this error in CI?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</PropertyGroup>

<PropertyGroup>
Expand Down
10 changes: 4 additions & 6 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<!-- This is false for local development, but set to true in the CI system -->
<TreatWarningsAsErrors Condition=" '$(TreatWarningsAsErrors)' == '' ">false</TreatWarningsAsErrors>

<!-- See https://github.com/dotnet/extensions/issues/4395 -->
<NoWarn>$(NoWarn);TBD</NoWarn>

<!-- TODO: to be re-enabled and all warnings fixed (https://github.com/dotnet/extensions/issues/4002) -->
<NoWarn>$(NoWarn);IL2026;IL2087;IL2067;IL2075;IL2091;IL2072;IL2090;CA1825;IL2070;IL2098;IL2057</NoWarn>

Expand All @@ -34,11 +37,6 @@
<NoWarn Condition="'$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0'">$(NoWarn);CA1062</NoWarn>
</PropertyGroup>

<!-- Ignore SuppressTfmSupportBuildWarnings warning for .NET Core 3.1 due to System.Diagnostic.DiagnosticSource 7.0.0 version -->
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<ItemGroup Condition="('$(Stage)' == 'normal' OR '$(Stage)' == 'obsolete') AND '$(OutputType)' != 'Exe' AND '$(IsPackable)' == 'true' AND '$(Api)' != 'false'">
<AdditionalFiles Include="$(MSBuildProjectName).json" Visible="False" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
Expand Down Expand Up @@ -86,7 +84,7 @@
</PropertyGroup>
</Target>

<!-- This target will make sure that projects targeting netcoreapp3.1 will also have the Microsoft.Extensions.Logging.Abstractions analyzer removed. -->
<!-- This target will make sure that projects targeting net462 will also have the Microsoft.Extensions.Logging.Abstractions analyzer removed. -->
Comment on lines -89 to +87
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joperezr I kept this target because the comment in Microsoft.Extensions.Telemetry.Abstractions.csproj refers to both net462 and netcoreapp3.1:
image

Please let me know, if I misunderstood it, and these should be removed.

<Target Name="_Microsoft_Extensions_Logging_AbstractionsRemoveAnalyzers"
Condition="'$(DisableMicrosoftExtensionsLoggingSourceGenerator)' == 'true'"
AfterTargets="ResolveReferences">
Expand Down
4 changes: 0 additions & 4 deletions eng/MSBuild/Packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
Condition="'$(MinimumSupportedTfmForPackaging)' != '' and
'$(ConditionalNet462)' != '' and
($(TargetFrameworks.Contains('$(MinimumSupportedTfmForPackaging)')) and $(TargetFrameworks.Contains('$(ConditionalNet462)')))" />
<NETStandardCompatError Include="netcoreapp3.1"
Supported="$(MinimumSupportedTfmForPackaging)"
Condition="'$(MinimumSupportedTfmForPackaging)' != '' and
($(TargetFrameworks.Contains('$(MinimumSupportedTfmForPackaging)')) and $(TargetFrameworks.Contains('netcoreapp3.1')))" />
</ItemGroup>

<!-- Verify that the minimum supported TFM is actually used. -->
Expand Down
4 changes: 0 additions & 4 deletions eng/packages/General.props
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,4 @@
<PackageVersion Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageVersion Include="Microsoft.AspNetCore.Http.Features" Version="3.1.22" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
</ItemGroup>
</Project>
5 changes: 0 additions & 5 deletions eng/packages/TestOnly.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.32" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="3.1.32" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.19" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="6.0.19" />
Expand Down
12 changes: 4 additions & 8 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
{
"sdk": {
"version": "8.0.100-rc.1.23381.2"
"version": "8.0.100-rc.2.23462.28"
},
"tools": {
"dotnet": "8.0.100-rc.1.23381.2",
"dotnet": "8.0.100-rc.2.23462.28",
"runtimes": {
"dotnet/x64": [
"3.1.32",
"6.0.16",
"7.0.5"
"6.0.22"
],
"aspnetcore/x64": [
"3.1.32",
"6.0.16",
"7.0.5"
"6.0.22"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void RegisterMethod(IMethodSymbol method, Action<OperationAnalysisContext
{
if (!_state.Methods.TryGetValue(method, out var l))
{
l = new();
l = [];
_state.Methods.Add(method, l);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ public void RegisterConstructor(IMethodSymbol ctor, Action<OperationAnalysisCont
{
if (!_state.Ctors.TryGetValue(ctor, out var l))
{
l = new();
l = [];
_state.Ctors.Add(ctor, l);
}

Expand Down Expand Up @@ -128,7 +128,7 @@ public void RegisterProperty(IPropertySymbol prop, Action<OperationAnalysisConte
{
if (!_state.Props.TryGetValue(prop, out var l))
{
l = new();
l = [];
_state.Props.Add(prop, l);
}

Expand Down Expand Up @@ -166,7 +166,7 @@ public void RegisterInterfaceMethod(IMethodSymbol method, Action<OperationAnalys
{
if (!_state.Interfaces.TryGetValue(method.ContainingType, out var handlers))
{
handlers = new();
handlers = [];
_state.Interfaces.Add(method.ContainingType, handlers);
}

Expand Down Expand Up @@ -227,7 +227,7 @@ public void RegisterExceptionTypes(string[] exceptionTypes, Action<OperationAnal
{
if (!_state.ExceptionTypes.TryGetValue(type, out var l))
{
l = new();
l = [];
_state.ExceptionTypes.Add(type, l);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void RegisterMethod(IMethodSymbol method, Action<OperationAnalysisContext
{
if (!_state.Methods.TryGetValue(method, out var l))
{
l = new();
l = [];
_state.Methods.Add(method, l);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ public void RegisterConstructor(IMethodSymbol ctor, Action<OperationAnalysisCont
{
if (!_state.Ctors.TryGetValue(ctor, out var l))
{
l = new();
l = [];
_state.Ctors.Add(ctor, l);
}

Expand Down Expand Up @@ -128,7 +128,7 @@ public void RegisterProperty(IPropertySymbol prop, Action<OperationAnalysisConte
{
if (!_state.Props.TryGetValue(prop, out var l))
{
l = new();
l = [];
_state.Props.Add(prop, l);
}

Expand Down Expand Up @@ -166,7 +166,7 @@ public void RegisterInterfaceMethod(IMethodSymbol method, Action<OperationAnalys
{
if (!_state.Interfaces.TryGetValue(method.ContainingType, out var handlers))
{
handlers = new();
handlers = [];
_state.Interfaces.Add(method.ContainingType, handlers);
}

Expand Down Expand Up @@ -227,7 +227,7 @@ public void RegisterExceptionTypes(string[] exceptionTypes, Action<OperationAnal
{
if (!_state.ExceptionTypes.TryGetValue(type, out var l))
{
l = new();
l = [];
_state.ExceptionTypes.Add(type, l);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Microsoft.Gen.AutoClient/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ internal sealed class Emitter : EmitterBase

public string EmitRestApis(IReadOnlyList<RestApiType> restApiTypes, CancellationToken cancellationToken)
{
Dictionary<string, List<RestApiType>> metricClassesDict = new();
Dictionary<string, List<RestApiType>> metricClassesDict = [];
foreach (var cl in restApiTypes)
{
if (!metricClassesDict.TryGetValue(cl.Namespace, out var list))
{
list = new List<RestApiType>();
list = [];
metricClassesDict.Add(cl.Namespace, list);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Generators/Microsoft.Gen.AutoClient/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private static ParseInterfaceAttributesResult ParseInterfaceAttributes(Immutable
{
string? httpClientName = null;
string? customDependencyName = null;
Dictionary<string, string> staticHeaders = new();
Dictionary<string, string> staticHeaders = [];

foreach (var classAttribute in classAttributes)
{
Expand Down Expand Up @@ -320,10 +320,10 @@ potentialNamespaceParent is not NamespaceDeclarationSyntax &&

private static ParseMethodAttributesResult ParseMethodAttributes(ImmutableArray<AttributeData> methodAttributes, SymbolHolder symbols)
{
List<string?> httpMethods = new();
List<string?> httpMethods = [];
string? requestName = null;
string? path = null;
Dictionary<string, string> staticHeaders = new();
Dictionary<string, string> staticHeaders = [];

foreach (var methodAttribute in methodAttributes)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Microsoft.Gen.Metrics/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ internal sealed class Emitter : EmitterBase

public string EmitMetrics(IReadOnlyList<MetricType> metricTypes, CancellationToken cancellationToken)
{
Dictionary<string, List<MetricType>> metricClassesDict = new();
Dictionary<string, List<MetricType>> metricClassesDict = [];
foreach (var cl in metricTypes)
{
if (!metricClassesDict.TryGetValue(cl.Namespace, out var list))
{
list = new List<MetricType>();
list = [];
metricClassesDict.Add(cl.Namespace, list);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Generators/Microsoft.Gen.Metrics/MetricFactoryEmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ internal sealed class MetricFactoryEmitter : EmitterBase
{
public string Emit(IReadOnlyList<MetricType> metricClasses, CancellationToken cancellationToken)
{
Dictionary<string, List<MetricType>> metricClassesDict = new();
Dictionary<string, List<MetricType>> metricClassesDict = [];
foreach (var cl in metricClasses)
{
if (!metricClassesDict.TryGetValue(cl.Namespace, out var list))
{
list = new List<MetricType>();
list = [];
metricClassesDict.Add(cl.Namespace, list);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<TargetFrameworks>$(NetCoreTargetFrameworks)$(ConditionalNet462)</TargetFrameworks>
<IsTrimmable Condition="'$(IsTrimmable)' == '' and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsTrimmable>
<IsTrimmable Condition="'$(IsTrimmable)' == '' and $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">true</IsTrimmable>

<InjectDiagnosticAttributesOnLegacy Condition="'$(InjectDiagnosticAttributesOnLegacy)' == ''">true</InjectDiagnosticAttributesOnLegacy>
<InjectIsExternalInitOnLegacy Condition="'$(InjectIsExternalInitOnLegacy)' == ''">true</InjectIsExternalInitOnLegacy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="System.Memory" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp3.1'))" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp3.1'))" />
<PackageReference Include="System.Memory" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp3.1'))" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp3.1'))" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))" />
<PackageReference Include="System.Collections.Immutable" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<PackageReference Include="Microsoft.Bcl.TimeProvider" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="System.Threading.Tasks.Extensions" Condition="'$(TargetFramework)' == 'net462'" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp3.1'))" />
<PackageReference Include="Microsoft.Bcl.HashCode" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Condition="'$(TargetFramework)' != 'net462'" />
<PackageReference Include="System.Collections.Immutable" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" />
<PackageReference Include="System.Text.Json" />
<PackageReference Include="System.Net.Http" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'netcoreapp3.1'))" />
<PackageReference Include="System.Net.Http" Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))" />
<PackageReference Include="System.Net.Http.Json" Condition="$([MSBuild]::VersionLessThan('$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)'))', '5.0'))" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques

if (context == null)
{
context = new Context();
context = [];
request.SetPolicyExecutionContext(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques

if (context == null)
{
context = new Context();
context = [];
request.SetPolicyExecutionContext(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Http.Resilience;
/// </summary>
public static class HttpRequestMessageExtensions
{
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
private static readonly HttpRequestOptionsKey<ResilienceContext?> _resilienceContextKey = new("Resilience.Http.ResilienceContext");
#else
private const string ResilienceContextKey = "Resilience.Http.ResilienceContext";
Expand All @@ -27,7 +27,7 @@ public static class HttpRequestMessageExtensions
{
_ = Throw.IfNull(requestMessage);

#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
if (requestMessage.Options.TryGetValue(_resilienceContextKey, out var context))
{
return context;
Expand All @@ -50,7 +50,7 @@ public static class HttpRequestMessageExtensions
public static void SetResilienceContext(this HttpRequestMessage requestMessage, ResilienceContext? resilienceContext)
{
_ = Throw.IfNull(requestMessage);
#if NET8_0_OR_GREATER
#if NET6_0_OR_GREATER
requestMessage.Options.Set(_resilienceContextKey, resilienceContext);
#else
requestMessage.Properties[ResilienceContextKey] = resilienceContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal sealed class WeightedGroupsRoutingStrategy : RequestRoutingStrategy
public WeightedGroupsRoutingStrategy(Randomizer randomizer, ObjectPool<WeightedGroupsRoutingStrategy> pool)
: base(randomizer)
{
_groups = new List<WeightedEndpointGroup>();
_groups = [];
_pool = pool;
}

Expand Down
Loading