Skip to content

Commit 52c861b

Browse files
authored
Added readonly modifier (#8386)
1 parent 768a9cf commit 52c861b

File tree

9 files changed

+12
-9
lines changed

9 files changed

+12
-9
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ dotnet_diagnostic.IDE0005.severity = warning
175175
dotnet_diagnostic.IDE0028.severity = warning
176176
# Order modifiers.
177177
dotnet_diagnostic.IDE0036.severity = warning
178+
# Add readonly modifier.
179+
dotnet_diagnostic.IDE0044.severity = warning
180+
dotnet_diagnostic.RCS1169.severity = none
178181
# Remove unused private member.
179182
dotnet_diagnostic.IDE0051.severity = warning
180183
dotnet_diagnostic.RCS1213.severity = none

src/HotChocolate/Core/src/Features/PooledFeatureCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public sealed class PooledFeatureCollection : IFeatureCollection
1515
private static readonly KeyComparer s_featureKeyComparer = new();
1616
private readonly Dictionary<Type, object> _features = [];
1717
private readonly List<KeyValuePair<Type, object>> _pooledFeatures = [];
18-
private object _state;
18+
private readonly object _state;
1919
private IFeatureCollection? _defaults;
2020
private volatile int _containerRevision;
2121

src/HotChocolate/Core/test/StarWars/Data/CharacterRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace HotChocolate.StarWars.Data;
55

66
public class CharacterRepository
77
{
8-
private Dictionary<string, ICharacter> _characters;
9-
private Dictionary<string, Starship> _starships;
8+
private readonly Dictionary<string, ICharacter> _characters;
9+
private readonly Dictionary<string, Starship> _starships;
1010

1111
public CharacterRepository()
1212
{

src/HotChocolate/Core/test/Subscriptions.Postgres.Tests/PostgresChannelTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public PostgresChannelTests(PostgreSqlResource resource, ITestOutputHelper outpu
2727
};
2828
}
2929

30-
private PostgresSubscriptionOptions _options;
30+
private readonly PostgresSubscriptionOptions _options;
3131

3232
[Fact]
3333
public async Task Subscribe_Should_ReceiveMessage_When_MessageIsSent()

src/HotChocolate/Core/test/Types.Analyzers.Tests/TestHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace HotChocolate.Types;
2121

2222
internal static partial class TestHelper
2323
{
24-
private static HashSet<string> s_ignoreCodes = ["CS8652", "CS8632", "CS5001", "CS8019"];
24+
private static readonly HashSet<string> s_ignoreCodes = ["CS8652", "CS8632", "CS5001", "CS8019"];
2525

2626
public static Snapshot GetGeneratedSourceSnapshot([StringSyntax("csharp")] string sourceText)
2727
{

src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/ObjectTypeDescriptorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public ValueTask InvokeAsync(IMiddlewareContext context)
245245

246246
public class TestFieldMiddleware2
247247
{
248-
private FieldDelegate _next;
248+
private readonly FieldDelegate _next;
249249

250250
public TestFieldMiddleware2(FieldDelegate next)
251251
{

src/HotChocolate/Spatial/test/Types.Tests/GeoJsonMultiPolygonSerializerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class GeoJsonMultiPolygonSerializerTests
4040
new IntValueNode(15),
4141
new IntValueNode(5)))));
4242

43-
private Geometry _geometry = new MultiPolygon(
43+
private readonly Geometry _geometry = new MultiPolygon(
4444
[
4545
new Polygon(
4646
new LinearRing(

src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Builders/XmlCommentBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace StrawberryShake.CodeGeneration.CSharp.Builders;
33
public class XmlCommentBuilder : ICodeBuilder
44
{
55
private string? _summary;
6-
private List<string> _code = [];
6+
private readonly List<string> _code = [];
77

88
public XmlCommentBuilder SetSummary(string summary)
99
{

src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/DependencyInjectionGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ private static ICode CreateBaseCode(CSharpSyntaxGeneratorSettings settings)
900900
.AddArgument(Sp)))));
901901
}
902902

903-
private static string s_clientServiceProvider =
903+
private static readonly string s_clientServiceProvider =
904904
@"private sealed class ClientServiceProvider
905905
: System.IServiceProvider
906906
, System.IDisposable

0 commit comments

Comments
 (0)