Update projects targeting net6 to net8 - part 2 (#9018)

* Second batch of projects to update from net6 to net8

* Remove the Core/TimeProvider in favor of System.TimeProvider in net8
This commit is contained in:
James Suplizio 2024-09-20 10:25:13 -07:00 коммит произвёл GitHub
Родитель b03fc8bfc8
Коммит 05465c2c5f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
28 изменённых файлов: 54 добавлений и 43 удалений

Просмотреть файл

@ -2,11 +2,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.159.1-preview" />
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="19.225.1" />
</ItemGroup>
</Project>

Просмотреть файл

@ -3,7 +3,7 @@
<PropertyGroup>
<VersionPrefix>0.2.0</VersionPrefix>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>

Просмотреть файл

@ -239,7 +239,7 @@ namespace Azure.Sdk.Tools.HttpFaultInjector
response.StatusCode = upstreamResponse.StatusCode;
foreach (var header in upstreamResponse.Headers)
{
response.Headers.Add(header.Key, header.Value);
response.Headers.Append(header.Key, header.Value);
}
_logger.LogInformation("Started writing response body, {actualLength}", contentBytes);

Просмотреть файл

@ -2,11 +2,11 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.22.0" />
</ItemGroup>
</Project>

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackAsTool>True</PackAsTool>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<PackAsTool>true</PackAsTool>

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PackAsTool>true</PackAsTool>
<ToolCommandName>pipeline-generator</ToolCommandName>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ApplicationInsightsResourceId>/subscriptions/a18897a6-7e44-457d-9260-f2854c0aca42/resourcegroups/sdk-bi-data/providers/microsoft.insights/components/azure-sdk-bi</ApplicationInsightsResourceId>
<ApplicationInsightsAnnotationResourceId>/subscriptions/a18897a6-7e44-457d-9260-f2854c0aca42/resourcegroups/sdk-bi-data/providers/microsoft.insights/components/azure-sdk-bi</ApplicationInsightsAnnotationResourceId>
<UserSecretsId>317bfab0-0fc1-4048-b61e-67e8f96c2b3a</UserSecretsId>
@ -13,7 +13,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
</ItemGroup>

Просмотреть файл

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -10,6 +10,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Hosting;
namespace PixelServer
{
@ -27,11 +28,11 @@ namespace PixelServer
{
services.AddMemoryCache();
services.AddApplicationInsightsTelemetry(Configuration);
services.AddMvcCore();
services.AddMvcCore(options => options.EnableEndpointRouting = false);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>

Просмотреть файл

@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.12.0" />
<PackageReference Include="Azure.ResourceManager.Authorization" Version="1.0.1" />

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>

Просмотреть файл

@ -23,7 +23,7 @@ public class RotateCommand : RotationCommandBase
bool onlyRotateExpiring = invocationContext.ParseResult.GetValueForOption(this.expiringOption);
bool whatIf = invocationContext.ParseResult.GetValueForOption(this.whatIfOption);
var timeProvider = new TimeProvider();
var timeProvider = TimeProvider.System;
IEnumerable<RotationPlan> plans = rotationConfiguration.GetAllRotationPlans(logger, timeProvider);
bool success = true;

Просмотреть файл

@ -14,7 +14,7 @@ public class StatusCommand : RotationCommandBase
protected override async Task HandleCommandAsync(ILogger logger, RotationConfiguration rotationConfiguration,
InvocationContext invocationContext)
{
var timeProvider = new TimeProvider();
var timeProvider = TimeProvider.System;
RotationPlan[] plans = rotationConfiguration.GetAllRotationPlans(logger, timeProvider).ToArray();
logger.LogInformation($"Getting status for {plans.Length} plans");

Просмотреть файл

@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.40.0" />
<PackageReference Include="Azure.Identity" Version="1.12.0" />

Просмотреть файл

@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Azure.Sdk.Tools.SecretRotation.Core\Azure.Sdk.Tools.SecretRotation.Core.csproj" />
</ItemGroup>

Просмотреть файл

@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>

Просмотреть файл

@ -54,7 +54,7 @@ public class RotationPlan
using IDisposable? loggingScope = this.logger.BeginScope(operationId);
this.logger.LogInformation("\nProcessing rotation plan '{PlanName}'", Name);
DateTimeOffset shouldRotateDate = this.timeProvider.GetCurrentDateTimeOffset().Add(RotationThreshold);
DateTimeOffset shouldRotateDate = this.timeProvider.GetUtcNow().Add(RotationThreshold);
this.logger.LogInformation("Getting current state of plan");
@ -88,7 +88,7 @@ public class RotationPlan
{
try
{
DateTimeOffset invocationTime = this.timeProvider.GetCurrentDateTimeOffset();
DateTimeOffset invocationTime = this.timeProvider.GetUtcNow();
SecretState primaryStoreState = await PrimaryStore.GetCurrentStateAsync();
@ -106,9 +106,9 @@ public class RotationPlan
SecretState[] allStates = secondaryStoreStates.Prepend(primaryStoreState).ToArray();
DateTimeOffset rotationThresholdDate = this.timeProvider.GetCurrentDateTimeOffset().Add(RotationThreshold);
DateTimeOffset rotationThresholdDate = this.timeProvider.GetUtcNow().Add(RotationThreshold);
DateTimeOffset warningThresholdDate = this.timeProvider.GetCurrentDateTimeOffset().Add(WarningThreshold);
DateTimeOffset warningThresholdDate = this.timeProvider.GetUtcNow().Add(WarningThreshold);
DateTimeOffset? minExpirationDate = allStates
.Where(x => x.ExpirationDate.HasValue)
@ -159,7 +159,7 @@ public class RotationPlan
* A user can combine origin and primary only when origin can be marked as complete in some way (e.g. Key Vault Certificates can be tagged)
*/
DateTimeOffset invocationTime = this.timeProvider.GetCurrentDateTimeOffset();
DateTimeOffset invocationTime = this.timeProvider.GetUtcNow();
SecretValue newValue = await OriginateNewValueAsync(operationId, invocationTime, currentState, whatIf);
// TODO: some providers will issue secrets for longer than we requested. Should we propagate the real expiration date, or the desired expiration date?
@ -244,7 +244,7 @@ public class RotationPlan
private async Task RevokeRotationArtifactsAsync(bool whatIf)
{
DateTimeOffset invocationTime = this.timeProvider.GetCurrentDateTimeOffset();
DateTimeOffset invocationTime = this.timeProvider.GetUtcNow();
IEnumerable<SecretState> rotationArtifacts = await PrimaryStore.GetRotationArtifactsAsync();

Просмотреть файл

@ -1,9 +0,0 @@
namespace Azure.Sdk.Tools.SecretRotation.Core;
public class TimeProvider
{
public virtual DateTimeOffset GetCurrentDateTimeOffset()
{
return DateTimeOffset.UtcNow;
}
}

Просмотреть файл

@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="Moq" Version="4.18.3" />

Просмотреть файл

@ -158,7 +158,7 @@ public class RotationConfigurationTests
RotationConfiguration configuration = RotationConfiguration.From(names, tags, configRoot, storeFactories);
// Act
IEnumerable<RotationPlan> plans = configuration.GetAllRotationPlans(Mock.Of<ILogger>(), new TimeProvider());
IEnumerable<RotationPlan> plans = configuration.GetAllRotationPlans(Mock.Of<ILogger>(), TimeProvider.System);
Assert.AreEqual(1, plans.Count());
}

Просмотреть файл

@ -58,7 +58,7 @@ public class RotationPlanTests
var rotationPlan = new RotationPlan(
Mock.Of<ILogger>(),
Mock.Of<TimeProvider>(x => x.GetCurrentDateTimeOffset() == staticTestTime),
Mock.Of<TimeProvider>(x => x.GetUtcNow() == staticTestTime),
"TestPlan",
Mock.Of<SecretStore>(),
Mock.Of<SecretStore>(x => x.GetCurrentStateAsync() == Task.FromResult(primaryState)),
@ -101,7 +101,7 @@ public class RotationPlanTests
var rotationPlan = new RotationPlan(
Mock.Of<ILogger>(),
Mock.Of<TimeProvider>(x => x.GetCurrentDateTimeOffset() == staticTestTime),
Mock.Of<TimeProvider>(x => x.GetUtcNow() == staticTestTime),
"TestPlan",
Mock.Of<SecretStore>(),
Mock.Of<SecretStore>(
@ -161,7 +161,7 @@ public class RotationPlanTests
var rotationPlan = new RotationPlan(
Mock.Of<ILogger>(),
Mock.Of<TimeProvider>(x => x.GetCurrentDateTimeOffset() == staticTestTime),
Mock.Of<TimeProvider>(x => x.GetUtcNow() == staticTestTime),
"TestPlan",
originStore,
primaryStore,

Просмотреть файл

@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<Description>Generates code snippets for readmes in the azure-sdk-for-net repo.</Description>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PackAsTool>true</PackAsTool>
<ToolCommandName>snippet-generator</ToolCommandName>
<VersionPrefix>1.0.0</VersionPrefix>