From 4797664aef68553ab869849cd67a74253ac90a0d Mon Sep 17 00:00:00 2001 From: Ben Villalobos <4691428+BenVillalobos@users.noreply.github.com> Date: Wed, 20 Jan 2021 08:36:36 -0800 Subject: [PATCH] Fix Nullable Warnings & projectcacheplugin.csproj now targets net5.0 (#6048) Fixes official builds after the arcade update. This failed because arcade CI had merged with a successful (but stale) CI build. --- .../Microsoft.Build.Engine.UnitTests.csproj | 2 +- .../BackEnd/Components/ProjectCache/ProjectCacheItem.cs | 8 ++++---- .../Components/ProjectCache/ProjectCacheService.cs | 2 +- src/Samples/ProjectCachePlugin/ProjectCachePlugin.csproj | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj index 9b45fb61b7e..dbb5365a805 100644 --- a/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj +++ b/src/Build.UnitTests/Microsoft.Build.Engine.UnitTests.csproj @@ -43,7 +43,7 @@ TargetFramework=$(FullFrameworkTFM) TargetFramework=$(FullFrameworkTFM) - TargetFramework=netcoreapp2.1 + TargetFramework=net5.0 diff --git a/src/Build/BackEnd/Components/ProjectCache/ProjectCacheItem.cs b/src/Build/BackEnd/Components/ProjectCache/ProjectCacheItem.cs index 21af5dd54ed..b1d781b1ca2 100644 --- a/src/Build/BackEnd/Components/ProjectCache/ProjectCacheItem.cs +++ b/src/Build/BackEnd/Components/ProjectCache/ProjectCacheItem.cs @@ -26,25 +26,25 @@ public ProjectCacheItem(string pluginPath, IReadOnlyDictionary p public string PluginPath { get; } public IReadOnlyDictionary PluginSettings { get; } - public bool Equals(ProjectCacheItem other) + public bool Equals(ProjectCacheItem? other) { if (ReferenceEquals(this, other)) { return true; } - return PluginPath == other.PluginPath && + return PluginPath == other?.PluginPath && CollectionHelpers.DictionaryEquals(PluginSettings, other.PluginSettings); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(this, obj)) { return true; } - if (obj.GetType() != GetType()) + if (obj?.GetType() != GetType()) { return false; } diff --git a/src/Build/BackEnd/Components/ProjectCache/ProjectCacheService.cs b/src/Build/BackEnd/Components/ProjectCache/ProjectCacheService.cs index 340d613c1c3..3103b05ddf6 100644 --- a/src/Build/BackEnd/Components/ProjectCache/ProjectCacheService.cs +++ b/src/Build/BackEnd/Components/ProjectCache/ProjectCacheService.cs @@ -92,7 +92,7 @@ private static ProjectCachePluginBase GetPluginInstanceFromType(Type pluginType) { try { - return (ProjectCachePluginBase) Activator.CreateInstance(pluginType); + return (ProjectCachePluginBase) Activator.CreateInstance(pluginType)!; } catch (TargetInvocationException e) when (e.InnerException != null) { diff --git a/src/Samples/ProjectCachePlugin/ProjectCachePlugin.csproj b/src/Samples/ProjectCachePlugin/ProjectCachePlugin.csproj index 9e1faa4fdbf..df35ae1ca6b 100644 --- a/src/Samples/ProjectCachePlugin/ProjectCachePlugin.csproj +++ b/src/Samples/ProjectCachePlugin/ProjectCachePlugin.csproj @@ -4,8 +4,8 @@ false false - netcoreapp2.1 - $(FullFrameworkTFM);netcoreapp2.1 + net5.0 + $(FullFrameworkTFM);net5.0 $(RuntimeOutputTargetFrameworks)