Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ resharper_enforce_using_statement_braces_highlighting = error
resharper_enforce_while_statement_braces_highlighting = error
resharper_redundant_string_format_call_highlighting = error
resharper_unused_variable_highlighting = warning
resharper_use_null_propagation_highlighting = warning
resharper_use_utf8_string_literal_highlighting = error
resharper_use_verbatim_string_highlighting = error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,9 +833,6 @@ internal static void SetQueryInterceptor(PagingQueryInterceptor pagingQueryInter

internal static void ClearQueryInterceptor()
{
if (s_interceptor.Value is not null)
{
s_interceptor.Value.Interceptor = null;
}
s_interceptor.Value?.Interceptor = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public static IResolverContext CreateResolverContext(
mock.SetupGet(c => c.ObjectType).Returns(type);
}

if (additionalMockSetup is not null)
{
additionalMockSetup(mock);
}
additionalMockSetup?.Invoke(mock);

var context = mock.Object;
context.ScopedContextData = ImmutableDictionary<string, object?>.Empty;
Expand Down
5 changes: 1 addition & 4 deletions src/HotChocolate/Core/src/Abstractions/ExtensionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ public bool ContainsKey(string key)

public void CopyTo(KeyValuePair<string, object?>[] array, int arrayIndex)
{
if (_dict is not null)
{
((ICollection<KeyValuePair<string, object?>>)_dict).CopyTo(array, arrayIndex);
}
((ICollection<KeyValuePair<string, object?>>?)_dict)?.CopyTo(array, arrayIndex);
}

public void Clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,8 @@ public static string SanitizeIdentifier(string input)
/// </summary>
public static string? EscapeForStringLiteral(string? s)
{
if (s == null)
{
return null;
}

return s.Replace("\\", "\\\\")
return s?
.Replace("\\", "\\\\")
.Replace("\"", "\\\"")
.Replace("\n", "\\n")
.Replace("\r", "\\r")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,8 @@ static void MaterializeParamRefElements(XDocument xDocument)
var methodName = qualifiedName.Substring(lastDotIndex + 1);

var typeSymbol = ResolveTypeSymbol(typeName, compilation);
if (typeSymbol == null)
{
return null;
}

return typeSymbol
return typeSymbol?
.GetMembers(methodName)
.OfType<IMethodSymbol>()
.FirstOrDefault(m => m.ToString() == documentationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
// Find the attribute
var node = root.FindNode(diagnosticSpan);
var attribute = node.AncestorsAndSelf().OfType<AttributeSyntax>().FirstOrDefault();
if (attribute is null)
{
return;
}

// Find the attribute list
var attributeList = attribute.Parent as AttributeListSyntax;
var attributeList = attribute?.Parent as AttributeListSyntax;
if (attributeList is null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
// Find the parameter
var node = root.FindNode(diagnosticSpan);
var parameter = node.AncestorsAndSelf().OfType<ParameterSyntax>().FirstOrDefault();
if (parameter is null)
{
return;
}

// Find the method declaration
var methodDeclaration = parameter.AncestorsAndSelf().OfType<MethodDeclarationSyntax>().FirstOrDefault();
var methodDeclaration = parameter?.AncestorsAndSelf().OfType<MethodDeclarationSyntax>().FirstOrDefault();
if (methodDeclaration is null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)

// Get the semantic model
var semanticModel = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false);
// ReSharper disable once UseNullPropagation - https://youtrack.jetbrains.com/issue/RSRP-503517
if (semanticModel is null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ internal override void OnBeforeCreateSchemaInternal(

if (enabled)
{
if (temp is not null)
{
temp[i++] = current;
}
temp?[i++] = current;

if (_mutationAggregator is null && current.IsMutationAggregator(context))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ private static ObjectValueNode Rewrite(
}
rewrittenItems[i] = rewritten;
}
else if (rewrittenItems is not null)
else
{
rewrittenItems[i] = node.Fields[i];
rewrittenItems?[i] = node.Fields[i];
}
}

Expand Down Expand Up @@ -193,9 +193,9 @@ private static ListValueNode Rewrite(
}
rewrittenItems[i] = rewritten;
}
else if (rewrittenItems is not null)
else
{
rewrittenItems[i] = node.Items[i];
rewrittenItems?[i] = node.Items[i];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,7 @@ public ObjectPool<StringBuilder> GetStringBuilderPool()

public T? GetService<T>() where T : class
{
if (_appServices is not null)
{
var service = _appServices.GetService<T?>();

if (service is not null)
{
return service;
}
}

return _schemaServices.GetService<T?>();
return _appServices?.GetService<T?>() ?? _schemaServices.GetService<T?>();
}
}
}
4 changes: 2 additions & 2 deletions src/HotChocolate/Core/src/Types/Types/Directive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ public DirectiveNode ToSyntaxNode(bool removeDefaults)
}
}
}
else if (rewrittenArguments is not null)
else
{
rewrittenArguments[index++] = arguments[i];
rewrittenArguments?[index++] = arguments[i];
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/HotChocolate/Core/test/Types.Tests/SchemaBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1923,10 +1923,7 @@ public override void Merge(IConventionContext context, Convention convention)
{
if (convention is MockConvention mockConvention)
{
if (mockConvention.Configuration != null)
{
mockConvention.Configuration.IsExtended = true;
}
mockConvention.Configuration?.IsExtended = true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ protected override async ValueTask<ExecutionStatus> OnExecuteAsync(
buffer.AsSpan(0, index).Clear();
ArrayPool<SourceSchemaResult>.Shared.Return(buffer);
}
else if (singleResult is not null)
else
{
singleResult.Dispose();
singleResult?.Dispose();
}

context.AddErrors(exception, variables, _resultSelectionSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,9 @@ void CompleteSelection<T>(T original, T? resolvable, T? unresolvable, int index)

static FieldNode? GetProvidedField(FieldNode fieldNode, SelectionSetNode? providedSelectionSetNode)
{
if (providedSelectionSetNode is not null)
{
return providedSelectionSetNode.Selections
.OfType<FieldNode>()
.FirstOrDefault(t => t.Name.Value.Equals(fieldNode.Name.Value));
}

return null;
return providedSelectionSetNode?.Selections
.OfType<FieldNode>()
.FirstOrDefault(t => t.Name.Value.Equals(fieldNode.Name.Value));
}

static SelectionSetNode? GetProvidedSelectionSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,12 +895,7 @@ public bool TryGetConditionalContextsWithReferences(

public void RemoveReferenceToConditionalContext(ISelectionNode selectionNode)
{
if (ReferencesInConditionalContexts is null)
{
return;
}

ReferencesInConditionalContexts.Remove(selectionNode);
ReferencesInConditionalContexts?.Remove(selectionNode);
}

public bool HasField(FieldNode fieldNode, out Context? fieldContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,10 @@ private ReceiveActivity(IReceiveContext context)
public void Dispose()
{
// Enrich activity with context state after all middlewares have run
if (_activity is not null)
{
_activity
.EnrichMessageDefault()
.SetMessageId(_context.MessageId ?? string.Empty)
.SetConversationId(_context.CorrelationId ?? string.Empty);
}
_activity?
.EnrichMessageDefault()
.SetMessageId(_context.MessageId ?? string.Empty)
.SetConversationId(_context.CorrelationId ?? string.Empty);

_activity?.Dispose();
}
Expand Down Expand Up @@ -151,15 +148,12 @@ public void Dispose()
var transportName = _context.Transport.Name;

// Enrich activity with context state after all middlewares have run
if (_activity is not null)
{
_activity
.SetMessageId(_context.MessageId ?? string.Empty)
.SetConversationId(_context.ConversationId ?? string.Empty)
.SetInstanceId(_context.Host.InstanceId)
.SetDestinationTemporary(false)
.SetDestinationAddress(destination);
}
_activity?
.SetMessageId(_context.MessageId ?? string.Empty)
.SetConversationId(_context.ConversationId ?? string.Empty)
.SetInstanceId(_context.Host.InstanceId)
.SetDestinationTemporary(false)
.SetDestinationAddress(destination);

_activity?.Dispose();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,7 @@ protected virtual Response<JsonDocument> CreateResponse(
MapVariables(list);
}

if (copy is not null)
{
copy[variable.Key] = value;
}
copy?[variable.Key] = value;
}

return copy ?? variables;
Expand Down
Loading