Merge pull request #12493 from dagood/fix-format-ref-usage

[ArPow] dotnet/format: Fix ref-only extensions package usage at runtime
This commit is contained in:
Michael Simons 2021-10-22 18:52:31 -05:00 committed by GitHub
commit 8a0b44e72f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,68 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Davis Goodin <dagood@microsoft.com>
Date: Fri, 22 Oct 2021 13:26:33 -0500
Subject: [PATCH] Fix MicrosoftExtensionsVersion
Move it to eng/Versions.props to make it overridable, and rename it to match an
actual package ID.
Update paramater nullability in src/Logging/SimpleConsoleLogger.cs to be
source-compatible with the 6.0 version of these packages.
See https://github.com/dotnet/format/issues/1400
---
Directory.Packages.props | 7 +++----
eng/Versions.props | 1 +
src/Logging/SimpleConsoleLogger.cs | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 6b628c2..9b579ea 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -2,7 +2,6 @@
<!-- <Import Project="eng\Versions.props" /> -->
<PropertyGroup>
- <MicrosoftExtensionsVersion>5.0.0</MicrosoftExtensionsVersion>
<!-- In order tests against the same version of NuGet as the SDK. We have to set this to match. -->
<NuGetVersion>6.0.0-preview.4.221</NuGetVersion>
</PropertyGroup>
@@ -25,9 +24,9 @@
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(MicrosoftNETCoreCompilersPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="$(MicrosoftNETCoreCompilersPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="$(MicrosoftNETCoreCompilersPackageVersion)" />
- <PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsVersion)" />
- <PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsVersion)" />
- <PackageVersion Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsVersion)" />
+ <PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(MicrosoftExtensionsDependencyInjectionVersion)" />
+ <PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsDependencyInjectionVersion)" />
+ <PackageVersion Include="Microsoft.Extensions.Logging" Version="$(MicrosoftExtensionsDependencyInjectionVersion)" />
<PackageVersion Include="NuGet.Common" Version="$(NuGetVersion)" />
<PackageVersion Include="NuGet.Configuration" Version="$(NuGetVersion)" />
<PackageVersion Include="NuGet.Frameworks" Version="$(NuGetVersion)" />
diff --git a/eng/Versions.props b/eng/Versions.props
index b1990aa..f6ddbbd 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -15,6 +15,7 @@
<PropertyGroup>
<MicrosoftBuildVersion>16.11.0</MicrosoftBuildVersion>
<MicrosoftCodeAnalysisAnalyzersVersion>3.3.2</MicrosoftCodeAnalysisAnalyzersVersion>
+ <MicrosoftExtensionsDependencyInjectionVersion>5.0.0</MicrosoftExtensionsDependencyInjectionVersion>
<!-- Dependencies from https://github.com/dotnet/roslyn -->
<MicrosoftNETCoreCompilersPackageVersion>4.0.0-6.21515.3</MicrosoftNETCoreCompilersPackageVersion>
<!-- Dependencies from https://github.com/dotnet/command-line-api -->
diff --git a/src/Logging/SimpleConsoleLogger.cs b/src/Logging/SimpleConsoleLogger.cs
index c361f84..fd8015c 100644
--- a/src/Logging/SimpleConsoleLogger.cs
+++ b/src/Logging/SimpleConsoleLogger.cs
@@ -37,7 +37,7 @@ namespace Microsoft.CodeAnalysis.Tools.Logging
_minimalErrorLevel = minimalErrorLevel;
}
- public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
+ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
if (!IsEnabled(logLevel))
{