Add vstest patch to resolve analyzer errors (#18123)

This commit is contained in:
Matt Thalman 2024-01-05 11:15:42 -06:00 committed by GitHub
parent 11788cb315
commit fb4ec09b1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 3 deletions

View file

@ -6,9 +6,6 @@
<BuildCommandArgs>$(BuildCommandArgs) /p:SemanticVersioningV1=true</BuildCommandArgs>
<BuildCommand>$(ProjectDirectory)\eng\common\build$(ShellExtension) $(BuildCommandArgs)</BuildCommand>
<DeterministicBuildOptOut>true</DeterministicBuildOptOut>
<!-- https://github.com/dotnet/source-build/issues/3814 -->
<NoWarn>$(NoWarn),IDE0044</NoWarn>
</PropertyGroup>
<ItemGroup>

View file

@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Matt Thalman <mthalman@microsoft.com>
Date: Fri, 5 Jan 2024 09:29:48 -0600
Subject: [PATCH] Set fields as readonly
Backport: https://github.com/microsoft/vstest/pull/4795
---
.../DesignMode/DesignModeClient.cs | 2 +-
.../ObjectModel/TestRun.cs | 2 +-
.../ObjectModel/TestType.cs | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs
index 4c1966a0..0657d284 100644
--- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs
+++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs
@@ -655,7 +655,7 @@ public class DesignModeClient : IDesignModeClient
#region IDisposable Support
private bool _isDisposed; // To detect redundant calls
- private bool _isForwardingOutput;
+ private readonly bool _isForwardingOutput;
protected virtual void Dispose(bool disposing)
{
diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRun.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRun.cs
index 228f5f2d..4bae23dd 100644
--- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRun.cs
+++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestRun.cs
@@ -30,7 +30,7 @@ internal sealed class TestRun
//
// The summary parsing code is in XmlTestReader.ReadTestRunSummary.
[StoreXmlSimpleField("@id")]
- private Guid _id;
+ private readonly Guid _id;
[StoreXmlSimpleField("@name")]
private string _name;
diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestType.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestType.cs
index fece20eb..a5e00b4a 100644
--- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestType.cs
+++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestType.cs
@@ -13,7 +13,7 @@ namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel;
internal sealed class TestType : IXmlTestStore
{
[StoreXmlSimpleField(".")]
- private Guid _typeId;
+ private readonly Guid _typeId;
public TestType(Guid id)
{