Skip to content

Commit 0e9d78f

Browse files
authored
Fixed various analyzer errors (#8417)
1 parent e8ca8cc commit 0e9d78f

File tree

13 files changed

+63
-7
lines changed

13 files changed

+63
-7
lines changed

src/GreenDonut/src/GreenDonut/DataLoaderBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ public abstract partial class DataLoaderBase<TKey, TValue>
3030
private readonly int _maxBatchSize;
3131
private readonly IDataLoaderDiagnosticEvents _diagnosticEvents;
3232
private ImmutableDictionary<string, IDataLoader> _branches =
33+
#if NET10_0_OR_GREATER
34+
[];
35+
#else
3336
ImmutableDictionary<string, IDataLoader>.Empty;
37+
#endif
3438
private Batch<TKey>? _currentBatch;
3539

3640
/// <summary>

src/HotChocolate/Core/src/Execution.Abstractions/Collections/Immutable/ImmutableOrderedDictionary.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ private ImmutableOrderedDictionary(ImmutableList<TKey> keys, ImmutableDictionary
3737
/// </summary>
3838
/// <value>An empty immutable ordered dictionary.</value>
3939
public static ImmutableOrderedDictionary<TKey, TValue> Empty { get; } =
40+
#if NET10_0_OR_GREATER
41+
new([], []);
42+
#else
4043
new([], ImmutableDictionary<TKey, TValue>.Empty);
44+
#endif
4145

4246
/// <summary>
4347
/// Gets the number of key/value pairs in the immutable ordered dictionary.

src/HotChocolate/Core/src/Execution.Abstractions/Execution/OperationResultBuilder.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ public OperationResultBuilder SetExtensions(IReadOnlyDictionary<string, object?>
7676
}
7777
else if (extensions is not null)
7878
{
79+
#if NET9_0_OR_GREATER
7980
_extensionData = new OrderedDictionary<string, object?>(extensions);
81+
#else
82+
_extensionData = [];
83+
#endif
8084
}
8185
else
8286
{
@@ -188,7 +192,11 @@ public static OperationResultBuilder FromResult(IOperationResult result)
188192
}
189193
else if (result.Extensions is not null)
190194
{
195+
#if NET9_0_OR_GREATER
191196
builder._extensionData = new OrderedDictionary<string, object?>(result.Extensions);
197+
#else
198+
builder._extensionData = [];
199+
#endif
192200
}
193201

194202
if (result.ContextData is Dictionary<string, object?> cd)

src/HotChocolate/Core/src/Execution/Processing/MiddlewareContext.Pooling.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ namespace HotChocolate.Execution.Processing;
55
internal partial class MiddlewareContext
66
{
77
private static readonly ImmutableDictionary<string, object?> s_emptyLocalContextData =
8+
#if NET10_0_OR_GREATER
9+
[];
10+
#else
811
ImmutableDictionary<string, object?>.Empty;
12+
#endif
913

1014
public MiddlewareContext()
1115
{

src/HotChocolate/Core/src/Execution/Processing/Operation.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ internal sealed class Operation : IOperation
1212
private readonly object _writeLock = new();
1313
private SelectionVariants[] _selectionVariants = [];
1414
private IncludeCondition[] _includeConditions = [];
15-
private ImmutableDictionary<string, object?> _contextData = ImmutableDictionary<string, object?>.Empty;
15+
private ImmutableDictionary<string, object?> _contextData =
16+
#if NET10_0_OR_GREATER
17+
[];
18+
#else
19+
ImmutableDictionary<string, object?>.Empty;
20+
#endif
1621
private bool _sealed;
1722

1823
public Operation(

src/HotChocolate/Core/src/Types.Abstractions/Polyfills/OrderedDictionary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class OrderedDictionary<TKey, TValue>
2424
/// </summary>
2525
public OrderedDictionary()
2626
{
27-
_map = new Dictionary<TKey, TValue>();
27+
_map = [];
2828
}
2929

3030
/// <summary>
@@ -36,7 +36,7 @@ public OrderedDictionary(IEnumerable<KeyValuePair<TKey, TValue>> collection)
3636
{
3737
ArgumentNullException.ThrowIfNull(collection);
3838

39-
_map = new Dictionary<TKey, TValue>();
39+
_map = [];
4040

4141
foreach (var (key, value) in collection)
4242
{

src/HotChocolate/Core/src/Types/Configuration/Features/TypeSystemConventionFeature.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ namespace HotChocolate.Configuration;
77
internal sealed class TypeSystemConventionFeature
88
{
99
public ImmutableDictionary<ConventionKey, ImmutableList<ConventionRegistration>> Conventions { get; set; } =
10+
#if NET10_0_OR_GREATER
11+
[];
12+
#else
1013
ImmutableDictionary<ConventionKey, ImmutableList<ConventionRegistration>>.Empty;
14+
#endif
1115
}

src/HotChocolate/Core/src/Types/Configuration/Features/TypeSystemFeature.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ internal sealed class TypeSystemFeature
1515
public Dictionary<string, Type> ScalarNameOverrides { get; } = [];
1616
public List<Action<ISchemaTypeDescriptor>> SchemaTypeOptions { get; } = [];
1717
public List<SchemaDocumentInfo> SchemaDocuments { get; } = [];
18+
#if NET10_0_OR_GREATER
19+
public ImmutableDictionary<string, IReadOnlyList<DirectiveNode>> ScalarDirectives { get; set; } =
20+
[];
21+
public ImmutableDictionary<Type, RuntimeTypeBinding> RuntimeTypeBindings { get; set; } =
22+
[];
23+
public ImmutableDictionary<Type, RuntimeTypeNameBinding> RuntimeTypeNameBindings { get; set; } =
24+
[];
25+
public ImmutableDictionary<string, RuntimeTypeNameBinding> NameRuntimeTypeBinding { get; set; } =
26+
[];
27+
#else
1828
public ImmutableDictionary<string, IReadOnlyList<DirectiveNode>> ScalarDirectives { get; set; } =
1929
ImmutableDictionary<string, IReadOnlyList<DirectiveNode>>.Empty;
2030
public ImmutableDictionary<Type, RuntimeTypeBinding> RuntimeTypeBindings { get; set; } =
@@ -23,4 +33,5 @@ internal sealed class TypeSystemFeature
2333
ImmutableDictionary<Type, RuntimeTypeNameBinding>.Empty;
2434
public ImmutableDictionary<string, RuntimeTypeNameBinding> NameRuntimeTypeBinding { get; set; } =
2535
ImmutableDictionary<string, RuntimeTypeNameBinding>.Empty;
36+
#endif
2637
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ private sealed class Error : ISchemaError
3333
IReadOnlyCollection<ISyntaxNode> ISchemaError.SyntaxNodes => SyntaxNodes;
3434

3535
public ImmutableDictionary<string, object> Extensions { get; set; }
36+
#if NET10_0_OR_GREATER
37+
= [];
38+
#else
3639
= ImmutableDictionary<string, object>.Empty;
40+
#endif
3741

3842
IReadOnlyDictionary<string, object> ISchemaError.Extensions => Extensions;
3943

src/HotChocolate/Core/src/Types/Types/Factories/SchemaFirstTypeInterceptor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ namespace HotChocolate.Types.Factories;
1313
internal sealed class SchemaFirstTypeInterceptor : TypeInterceptor
1414
{
1515
private ImmutableDictionary<string, IReadOnlyList<DirectiveNode>> _directives =
16+
#if NET10_0_OR_GREATER
17+
[];
18+
#else
1619
ImmutableDictionary<string, IReadOnlyList<DirectiveNode>>.Empty;
20+
#endif
1721

1822
internal override void InitializeContext(
1923
IDescriptorContext context,

0 commit comments

Comments
 (0)