Skip to content

Commit cd6bbc5

Browse files
authored
Updated code to remove redundant 'ToString' calls (#8348)
1 parent 5160442 commit cd6bbc5

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ dotnet_style_prefer_collection_expression = when_types_exactly_match
193193
# Remove unnecessary blank line.
194194
dotnet_diagnostic.RCS0063.severity = warning
195195
dotnet_diagnostic.RCS1036.severity = none # see https://github.com/dotnet/roslynator/issues/1632
196+
# Remove redundant 'ToString' call.
197+
dotnet_diagnostic.RCS1097.severity = warning
196198
# Unnecessary null-forgiving operator.
197199
dotnet_diagnostic.RCS1249.severity = warning
198200
# Remove unnecessary braces.

src/HotChocolate/Core/src/Types/SchemaPrinter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static DocumentNode PrintSchema(
9393
var directiveTypeDefinitions =
9494
schema.DirectiveTypes
9595
.Where(directive => !builtInDirectives.Contains(directive.Name))
96-
.OrderBy(t => t.Name.ToString(), StringComparer.Ordinal)
96+
.OrderBy(t => t.Name, StringComparer.Ordinal)
9797
.Select(PrintDirectiveTypeDefinition);
9898

9999
typeDefinitions.AddRange(directiveTypeDefinitions);
@@ -102,7 +102,7 @@ public static DocumentNode PrintSchema(
102102
schema.Types
103103
.OfType<ScalarType>()
104104
.Where(t => includeSpecScalars || !BuiltInTypes.IsBuiltInType(t.Name))
105-
.OrderBy(t => t.Name.ToString(), StringComparer.Ordinal)
105+
.OrderBy(t => t.Name, StringComparer.Ordinal)
106106
.Select(PrintScalarType);
107107

108108
typeDefinitions.AddRange(scalarTypeDefinitions);
@@ -115,7 +115,7 @@ private static IEnumerable<ITypeDefinition> GetNonScalarTypes(
115115
{
116116
return schema.Types
117117
.Where(IsPublicAndNoScalar)
118-
.OrderBy(t => t.Name.ToString(), StringComparer.Ordinal)
118+
.OrderBy(t => t.Name, StringComparer.Ordinal)
119119
.GroupBy(t => (int)t.Kind)
120120
.OrderBy(t => t.Key)
121121
.SelectMany(t => t);

src/HotChocolate/Core/test/Types.Tests/Configuration/TypeInitializerTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Register_SchemaType_ClrTypeExists()
3838
Assert.True(exists);
3939
var fooType =
4040
Assert.IsType<FooType>(type.Type).Fields.ToDictionary(
41-
t => t.Name.ToString(),
41+
t => t.Name,
4242
t => t.Type.Print());
4343

4444
exists = typeRegistry.TryGetType(
@@ -48,7 +48,7 @@ public void Register_SchemaType_ClrTypeExists()
4848
Assert.True(exists);
4949
var barType =
5050
Assert.IsType<BarType>(type.Type).Fields.ToDictionary(
51-
t => t.Name.ToString(),
51+
t => t.Name,
5252
t => t.Type.Print());
5353

5454
new { fooType, barType }.MatchSnapshot();
@@ -93,7 +93,7 @@ public void Register_ClrType_InferSchemaTypes()
9393
Assert.True(exists);
9494
var fooType =
9595
Assert.IsType<ObjectType<Foo>>(type.Type).Fields.ToDictionary(
96-
t => t.Name.ToString(),
96+
t => t.Name,
9797
t => t.Type.Print());
9898

9999
exists = typeRegistry.TryGetType(
@@ -103,7 +103,7 @@ public void Register_ClrType_InferSchemaTypes()
103103
Assert.True(exists);
104104
var barType =
105105
Assert.IsType<ObjectType<Bar>>(type.Type).Fields.ToDictionary(
106-
t => t.Name.ToString(),
106+
t => t.Name,
107107
t => t.Type.Print());
108108

109109
new { fooType, barType }.MatchSnapshot();

0 commit comments

Comments
 (0)