From e459ba555ebf5102aaa9a9bc8b1f82238f34b676 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Thu, 28 Mar 2024 17:47:04 +1100 Subject: [PATCH] Fix some warnings in the IDE I turned on solution-wide analysis and these appeared in the error list. --- .editorconfig | 4 +++- tests/Common/ThrowingTraceListener.cs | 2 ++ .../ProjectSystem/VS/ComponentVerificationTests.cs | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1c4c4de8753..0d7d396d7f7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -393,6 +393,7 @@ dotnet_diagnostic.IDE0090.severity = warning # Use new(...) dotnet_diagnostic.IDE0220.severity = warning # Add explicit cast dotnet_diagnostic.IDE0250.severity = warning # Struct can be made 'readonly' dotnet_diagnostic.IDE0251.severity = suggestion # Struct methods can be made 'readonly' +dotnet_diagnostic.IDE0270.severity = suggestion # Use coalesce expression dotnet_diagnostic.IDE1006.severity = warning # Naming styles Task Open() Task OpenAsync() dotnet_diagnostic.IDE1006WithoutSuggestion.severity = suggestion @@ -442,4 +443,5 @@ dotnet_diagnostic.CA1307.severity = suggestion # Specify StringComparison # Disabling warning for C# files generated from xaml rules [artifacts/*/obj/Microsoft.VisualStudio.ProjectSystem.Managed/net8.0/*.cs] # CS0618: Type or member is obsolete -dotnet_diagnostic.CS0618.severity = silent \ No newline at end of file +dotnet_diagnostic.CS0618.severity = silent + diff --git a/tests/Common/ThrowingTraceListener.cs b/tests/Common/ThrowingTraceListener.cs index 316959811fb..31c4d3ff998 100644 --- a/tests/Common/ThrowingTraceListener.cs +++ b/tests/Common/ThrowingTraceListener.cs @@ -1,7 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information. using System.Diagnostics; +#if !NET8_0_OR_GREATER using System.Runtime.Serialization; +#endif namespace Microsoft.VisualStudio.Diagnostics { diff --git a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/ComponentVerificationTests.cs b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/ComponentVerificationTests.cs index 20285e8a77d..5148e9d18c3 100644 --- a/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/ComponentVerificationTests.cs +++ b/tests/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/ProjectSystem/VS/ComponentVerificationTests.cs @@ -21,8 +21,8 @@ public void ImportsMustFilterBasedOnCapabilities(Type type) foreach ((ImportDefinitionBinding import, IReadOnlyList exports) in part.SatisfyingExports) { - var importingProperty = import.ImportingMember as PropertyInfo; - if (importingProperty is null) // We don't verify ImportingConstructor, only check properties. + // Only check properties. We don't verify ImportingConstructor. + if (import.ImportingMember is not PropertyInfo importingProperty) return; Type memberType = importingProperty.PropertyType;