Skip to content

Commit 7f69d74

Browse files
authored
Reenable compound assignment preference (PowerShell#17784)
1 parent 5f4e100 commit 7f69d74

File tree

5 files changed

+8
-19
lines changed

5 files changed

+8
-19
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent
114114
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
115115
dotnet_style_prefer_auto_properties = true:suggestion
116116
csharp_prefer_simple_default_expression = true:suggestion
117-
dotnet_style_prefer_compound_assignment = false:silent
118117
dotnet_diagnostic.IDE0031.severity = none
119118

120119
dotnet_code_quality_unused_parameters = non_public:suggestion

src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,9 @@ private static IList<DefaultPSSnapInInformation> DefaultMshSnapins
12841284
{
12851285
lock (s_syncObject)
12861286
{
1287+
#pragma warning disable IDE0074 // Disabling the rule because it can't be applied on non Unix
12871288
if (s_defaultMshSnapins == null)
1289+
#pragma warning restore IDE0074
12881290
{
12891291
s_defaultMshSnapins = new List<DefaultPSSnapInInformation>()
12901292
{

src/System.Management.Automation/utils/tracing/PSSysLogProvider.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ private static StringBuilder PayloadBuilder
4949
{
5050
get
5151
{
52-
if (t_payloadBuilder == null)
53-
{
54-
// NOTE: Thread static fields must be explicitly initialized for each thread.
55-
t_payloadBuilder = new StringBuilder(200);
56-
}
52+
// NOTE: Thread static fields must be explicitly initialized for each thread.
53+
t_payloadBuilder ??= new StringBuilder(200);
5754

5855
return t_payloadBuilder;
5956
}

src/System.Management.Automation/utils/tracing/SysLogProvider.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,8 @@ private static StringBuilder MessageBuilder
130130
{
131131
get
132132
{
133-
if (t_messageBuilder == null)
134-
{
135-
// NOTE: Thread static fields must be explicitly initialized for each thread.
136-
t_messageBuilder = new StringBuilder(200);
137-
}
133+
// NOTE: Thread static fields must be explicitly initialized for each thread.
134+
t_messageBuilder ??= new StringBuilder(200);
138135

139136
return t_messageBuilder;
140137
}
@@ -201,10 +198,7 @@ private bool ShouldLog(PSLevel level, PSKeyword keywords, PSChannel channel)
201198
{
202199
get
203200
{
204-
if (_resourceManager is null)
205-
{
206-
_resourceManager = new global::System.Resources.ResourceManager("System.Management.Automation.resources.EventResource", typeof(EventResource).Assembly);
207-
}
201+
_resourceManager ??= new global::System.Resources.ResourceManager("System.Management.Automation.resources.EventResource", typeof(EventResource).Assembly);
208202

209203
return _resourceManager;
210204
}

test/tools/WebListener/Controllers/RetryController.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ public class RetryController : Controller
2323

2424
public JsonResult Retry(string sessionId, int failureCode, int failureCount)
2525
{
26-
if (retryInfo == null)
27-
{
28-
retryInfo = new Dictionary<string, Tuple<int, int, int>>();
29-
}
26+
retryInfo ??= new Dictionary<string, Tuple<int, int, int>>();
3027

3128
if (retryInfo.TryGetValue(sessionId, out Tuple<int, int, int> retry))
3229
{

0 commit comments

Comments
 (0)