Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make property readonly when possible #3320

Merged
merged 3 commits into from
Feb 3, 2022

Conversation

Evangelink
Copy link
Member

No description provided.

@@ -210,12 +210,12 @@ public DiscoveryCriteria DiscoveryCriteria
/// <summary>
/// Parent discovery manager
/// </summary>
internal IProxyDiscoveryManager DiscoveryManager { get; private set; }
internal IProxyDiscoveryManager DiscoveryManager { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -102,7 +102,7 @@ public LazyExtension(Func<TExtension> creator, TMetadata metadata)
/// </summary>
internal bool IsExtensionCreated { get; private set; }

internal TestPluginInformation TestPluginInfo { get; private set; }
internal TestPluginInformation TestPluginInfo { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.


/// <summary>
/// Gets the map of settings name to settings provider.
/// </summary>
public Dictionary<string, LazyExtension<ISettingsProvider, ISettingsProviderCapabilities>> SettingsProvidersMap { get; private set; }
public Dictionary<string, LazyExtension<ISettingsProvider, ISettingsProviderCapabilities>> SettingsProvidersMap { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -66,7 +66,7 @@ public ParallelRunDataAggregator(string runSettingsXml)

public bool IsCanceled { get; private set; }

public string RunSettings { get; private set; }
public string RunSettings { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -157,17 +179,17 @@ internal abstract class BaseRunTests
/// <summary>
/// Gets the run settings.
/// </summary>
protected string RunSettings { get; private set; }
protected string RunSettings { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.


/// <summary>
/// Gets the test execution context.
/// </summary>
protected TestExecutionContext TestExecutionContext { get; private set; }
protected TestExecutionContext TestExecutionContext { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.


/// <summary>
/// Gets the test run events handler.
/// </summary>
protected ITestRunEventsHandler TestRunEventsHandler { get; private set; }
protected ITestRunEventsHandler TestRunEventsHandler { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -38,12 +38,12 @@ public TestLink(Guid id, string name, string storage)
/// <summary>
/// Gets the name.
/// </summary>
public string Name { get; private set; } = string.Empty;
public string Name { get; } = string.Empty;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -113,7 +113,7 @@ public static TestListCategory AllResults
/// <summary>
/// Gets the id.
/// </summary>
public TestListCategoryId Id { get; private set; } = new TestListCategoryId();
public TestListCategoryId Id { get; } = new TestListCategoryId();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.


/// <summary>
/// Gets the class name.
/// </summary>
public string ClassName { get; private set; }
public string ClassName { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -297,7 +297,7 @@ public TimeSpan Duration
/// <summary>
/// Gets the computer name.
/// </summary>
public string ComputerName { get; private set; }
public string ComputerName { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -408,7 +408,7 @@ public string TestResultsDirectory
/// <summary>
/// Gets the directory containing the test result files, relative to the root results directory
/// </summary>
public string RelativeTestResultsDirectory { get; private set; }
public string RelativeTestResultsDirectory { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -51,7 +51,7 @@ public override TestType TestType
/// <summary>
/// Gets the test method.
/// </summary>
public TestMethod TestMethod { get; private set; }
public TestMethod TestMethod { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -77,7 +77,7 @@ internal static ArgumentProcessorFactory Create()
/// <summary>
/// Returns all of the available argument processors.
/// </summary>
public IEnumerable<IArgumentProcessor> AllArgumentProcessors { get; private set; }
public IEnumerable<IArgumentProcessor> AllArgumentProcessors { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -60,7 +60,7 @@ internal string TraceFileName
/// <value>
/// The <see cref="StreamWriterRollingHelper"/> for the flat file.
/// </value>
internal StreamWriterRollingHelper RollingHelper { get; private set; }
internal StreamWriterRollingHelper RollingHelper { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -20,7 +20,7 @@ public sealed class TestHostLaunchedEventArgs : DataCollectionEventArgs

#region Public properties

public int TestHostProcessId { get; private set; }
public int TestHostProcessId { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -85,14 +85,14 @@ protected internal DataCollectionContext(SessionId sessionId, TestCase testCase)
/// Identifies the session under which the data collection occurs. Will not be null.
/// </summary>
[DataMember]
public SessionId SessionId { get; private set; }
public SessionId SessionId { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.


/// <summary>
/// Identifies the test execution under which the data collection occurs,
/// or null if no such test exists.
/// </summary>
[DataMember]
public TestExecId TestExecId { get; private set; }
public TestExecId TestExecId { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was badly refactored by the code-fix because the field was not readonly.

@@ -85,14 +85,14 @@ protected internal DataCollectionContext(SessionId sessionId, TestCase testCase)
/// Identifies the session under which the data collection occurs. Will not be null.
/// </summary>
[DataMember]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REVIEW ME: Changes on this type are related to some DataMember so there might have been some impact on serialization although this doesn't seem to be part of any old serialization path (XmlSerializer).

@nohwnd
Copy link
Member

nohwnd commented Feb 3, 2022

Not sure what is required of me in this PR. Should the lines marked as "incorrectly refactored" be reverted? Or what am I approving here?

@Evangelink
Copy link
Member Author

@nohwnd I have called out all cases where we used to have a readonly property (with a non-static field) before doing the big code style PR. Except for the case where there is a REVIEW ME comment, I don't expect any problem. All the changes without comment are simple follow-up refactorings (i.e. it was not readonly before but could have been changed so I am doing the change).

@Evangelink Evangelink merged commit cc10486 into microsoft:main Feb 3, 2022
@Evangelink Evangelink deleted the readonly-properties branch February 3, 2022 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants