Skip to content

Commit 646700f

Browse files
authored
Used compound assignment (#8390)
1 parent cd76363 commit 646700f

File tree

12 files changed

+30
-64
lines changed

12 files changed

+30
-64
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,14 @@ dotnet_diagnostic.IDE0051.severity = warning
183183
dotnet_diagnostic.RCS1213.severity = none
184184
# Remove unread private member.
185185
dotnet_diagnostic.IDE0052.severity = warning
186+
# Use compound assignment.
187+
dotnet_diagnostic.IDE0054.severity = warning
186188
# Formatting rule.
187189
dotnet_diagnostic.IDE0055.severity = warning
188190
# Use range operator.
189191
dotnet_diagnostic.IDE0057.severity = warning
192+
# Use compound assignment.
193+
dotnet_diagnostic.IDE0074.severity = warning
190194
# Use pattern matching (not operator).
191195
dotnet_diagnostic.IDE0083.severity = warning
192196
# Use collection expression for array.

src/GreenDonut/src/GreenDonut.Data.EntityFramework/Extensions/PagingQueryableExtensions.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,7 @@ private sealed class InterceptorHolder
689689

690690
internal static void SetQueryInterceptor(PagingQueryInterceptor pagingQueryInterceptor)
691691
{
692-
if (s_interceptor.Value is null)
693-
{
694-
s_interceptor.Value = new InterceptorHolder();
695-
}
696-
692+
s_interceptor.Value ??= new InterceptorHolder();
697693
s_interceptor.Value.Interceptor = pagingQueryInterceptor;
698694
}
699695

src/HotChocolate/AzureFunctions/src/HotChocolate.AzureFunctions.IsolatedProcess/AzureHttpResponse.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ internal HttpResponseData ResponseData
2727
{
2828
lock (_sync)
2929
{
30-
if (_responseData is null)
31-
{
32-
_responseData = _requestData.CreateResponse();
33-
}
30+
_responseData ??= _requestData.CreateResponse();
3431
}
3532
}
3633

@@ -54,10 +51,7 @@ public override IHeaderDictionary Headers
5451
{
5552
lock (_sync)
5653
{
57-
if (_headers is null)
58-
{
59-
_headers = new AzureHeaderDictionary(_response, ResponseData);
60-
}
54+
_headers ??= new AzureHeaderDictionary(_response, ResponseData);
6155
}
6256
}
6357
return _headers;

src/HotChocolate/Core/src/Execution/Configuration/ConfigurationContext.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ public IDescriptorContext DescriptorContext
6464
{
6565
get
6666
{
67-
if (_descriptorContext is null)
68-
{
69-
_descriptorContext = SchemaBuilder.CreateContext();
70-
}
67+
_descriptorContext ??= SchemaBuilder.CreateContext();
7168

7269
return _descriptorContext;
7370
}

src/HotChocolate/Core/src/Execution/DependencyInjection/Factories/DeferredWorkStateOwnerFactory.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ public DeferredWorkStateOwner Create()
3030
{
3131
lock (_sync)
3232
{
33-
if (_owner is null)
34-
{
35-
_owner = new DeferredWorkStateOwner(_pool);
36-
}
33+
_owner ??= new DeferredWorkStateOwner(_pool);
3734
}
3835
}
3936

src/HotChocolate/Core/src/Types.CursorPagination/Extensions/PagingObjectFieldDescriptorExtensions.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,11 @@ private static TypeReference CreateConnectionTypeRef(
319319
{
320320
var typeInspector = context.TypeInspector;
321321

322-
if (nodeType is null)
323-
{
324-
// if there is no explicit node type provided we will try and
325-
// infer the schema type from the resolver member.
326-
nodeType = TypeReference.Create(
327-
PagingHelper.GetSchemaType(context, resolverMember),
328-
TypeContext.Output);
329-
}
322+
// if there is no explicit node type provided we will try and
323+
// infer the schema type from the resolver member.
324+
nodeType ??= TypeReference.Create(
325+
PagingHelper.GetSchemaType(context, resolverMember),
326+
TypeContext.Output);
330327

331328
// if the node type is a syntax type reference we will try to preserve the actual
332329
// runtime type for later usage.

src/HotChocolate/Core/src/Types/Internal/ExtendedType.Members.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ private static ExtendedType Rewrite(
9595
}
9696
}
9797

98-
if (elementType is null)
99-
{
100-
elementType = ExtendedType.FromType(itemType, cache);
101-
}
98+
elementType ??= ExtendedType.FromType(itemType, cache);
10299
}
103100

104101
if (extendedType.IsArray && elementType is null)

src/HotChocolate/Core/src/Types/Resolvers/FieldMember.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ public override string ToString()
138138

139139
public FieldReference ToFieldReference()
140140
{
141-
if (_fieldReference is null)
142-
{
143-
_fieldReference = new FieldReference(TypeName, FieldName);
144-
}
141+
_fieldReference ??= new FieldReference(TypeName, FieldName);
145142
return _fieldReference;
146143
}
147144
}

src/HotChocolate/Core/src/Types/SchemaErrorBuilder.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ public SchemaErrorBuilder SetExtension(string key, object value)
5858
public SchemaErrorBuilder SetException(Exception exception)
5959
{
6060
_error.Exception = exception;
61-
if (_error.Message is null)
62-
{
63-
_error.Message = exception.Message;
64-
}
61+
_error.Message ??= exception.Message;
6562
return this;
6663
}
6764

src/HotChocolate/Core/src/Types/Types/Descriptors/Conventions/DescriptorContext.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,14 @@ public INamingConventions Naming
6666
{
6767
get
6868
{
69-
if (_naming is null)
70-
{
71-
_naming = GetConventionOrDefault<INamingConventions>(() => Options.UseXmlDocumentation
72-
? new DefaultNamingConventions(
73-
new XmlDocumentationProvider(
74-
new XmlDocumentationFileResolver(
75-
Options.ResolveXmlDocumentationFileName),
76-
_serviceHelper.GetStringBuilderPool()))
77-
: new DefaultNamingConventions(
78-
new NoopDocumentationProvider()));
79-
}
69+
_naming ??= GetConventionOrDefault<INamingConventions>(() => Options.UseXmlDocumentation
70+
? new DefaultNamingConventions(
71+
new XmlDocumentationProvider(
72+
new XmlDocumentationFileResolver(
73+
Options.ResolveXmlDocumentationFileName),
74+
_serviceHelper.GetStringBuilderPool()))
75+
: new DefaultNamingConventions(
76+
new NoopDocumentationProvider()));
8077

8178
return _naming;
8279
}
@@ -87,11 +84,8 @@ public ITypeInspector TypeInspector
8784
{
8885
get
8986
{
90-
if (_inspector is null)
91-
{
92-
_inspector = this.GetConventionOrDefault<ITypeInspector>(
93-
new DefaultTypeInspector());
94-
}
87+
_inspector ??= this.GetConventionOrDefault<ITypeInspector>(
88+
new DefaultTypeInspector());
9589

9690
return _inspector;
9791
}

0 commit comments

Comments
 (0)