Skip to content

Commit 944b800

Browse files
authored
Used raw string literals (#8708)
1 parent 477421b commit 944b800

File tree

81 files changed

+1592
-1328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1592
-1328
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ dotnet_diagnostic.RCS1260.severity = warning
283283
roslynator_trailing_comma_style = omit
284284
# Resource can be disposed asynchronously.
285285
dotnet_diagnostic.RCS1261.severity = warning
286+
# Use raw string literal.
287+
dotnet_diagnostic.RCS1266.severity = warning
286288
# Unnecessary conditional access.
287289
dotnet_diagnostic.RCS9003.severity = warning
288290

src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Opa.Tests/AuthorizationTestData.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ namespace HotChocolate.AspNetCore.Authorization;
88

99
public class AuthorizationTestData : IEnumerable<object[]>
1010
{
11-
private const string Sdl = $@"
12-
type Query {{
11+
private const string Sdl =
12+
$$"""
13+
type Query {
1314
default: String @authorize
14-
age: String @authorize(policy: ""{Policies.HasDefinedAge}"")
15-
roles: String @authorize(roles: [""a""])
16-
roles_ab: String @authorize(roles: [""a"" ""b""])
15+
age: String @authorize(policy: "{{Policies.HasDefinedAge}}")
16+
roles: String @authorize(roles: ["a"])
17+
roles_ab: String @authorize(roles: ["a", "b"])
1718
piped: String
18-
@authorize(policy: ""a"")
19-
@authorize(policy: ""b"")
19+
@authorize(policy: "a")
20+
@authorize(policy: "b")
2021
afterResolver: String
21-
@authorize(policy: ""a"" apply: AFTER_RESOLVER)
22-
}}";
22+
@authorize(policy: "a", apply: AFTER_RESOLVER)
23+
}
24+
""";
2325

2426
private readonly FieldMiddleware _schemaMiddleware = next => context =>
2527
{

src/HotChocolate/AspNetCore/test/AspNetCore.Authorization.Tests/AuthorizationTestData.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ namespace HotChocolate.AspNetCore.Authorization;
77

88
public class AuthorizationTestData : IEnumerable<object[]>
99
{
10-
private readonly string _schemaCode = @"
10+
private readonly string _schemaCode =
11+
// lang=graphql
12+
"""
1113
type Query {
1214
default: String @authorize(apply: BEFORE_RESOLVER)
13-
age: String @authorize(policy: ""HasAgeDefined"" apply: BEFORE_RESOLVER)
14-
roles: String @authorize(roles: [""a""] apply: BEFORE_RESOLVER)
15-
roles_ab: String @authorize(roles: [""a"" ""b""] apply: BEFORE_RESOLVER)
16-
rolesAndPolicy: String @authorize(roles: [""a"" ""b""] policy: ""HasAgeDefined"" apply: BEFORE_RESOLVER)
15+
age: String @authorize(policy: "HasAgeDefined", apply: BEFORE_RESOLVER)
16+
roles: String @authorize(roles: ["a"], apply: BEFORE_RESOLVER)
17+
roles_ab: String @authorize(roles: ["a", "b"], apply: BEFORE_RESOLVER)
18+
rolesAndPolicy: String @authorize(roles: ["a", "b"], policy: "HasAgeDefined", apply: BEFORE_RESOLVER)
1719
piped: String
18-
@authorize(policy: ""a"" apply: BEFORE_RESOLVER)
19-
@authorize(policy: ""b"" apply: BEFORE_RESOLVER)
20+
@authorize(policy: "a", apply: BEFORE_RESOLVER)
21+
@authorize(policy: "b", apply: BEFORE_RESOLVER)
2022
afterResolver: String
21-
@authorize(policy: ""a"" apply: AFTER_RESOLVER)
22-
}";
23+
@authorize(policy: "a", apply: AFTER_RESOLVER)
24+
}
25+
""";
2326

2427
private readonly FieldMiddleware _schemaMiddleware = next => context =>
2528
{

src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ClientQueryRequest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics.CodeAnalysis;
12
using System.Text;
23
using Newtonsoft.Json;
34

@@ -12,6 +13,7 @@ public class ClientQueryRequest
1213
public string? OperationName { get; set; }
1314

1415
[JsonProperty("query")]
16+
[StringSyntax("graphql")]
1517
public string? Query { get; set; }
1618

1719
[JsonProperty("variables")]

src/HotChocolate/AspNetCore/test/AspNetCore.Tests/GraphQLOverHttpSpecTests.cs

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,20 @@ public async Task SingleResult_MultipartAcceptHeader(string acceptHeader)
9898
.Create()
9999
.Add(response)
100100
.MatchInline(
101-
@"Headers:
102-
Content-Type: multipart/mixed; boundary=""-""
101+
"""
102+
Headers:
103+
Content-Type: multipart/mixed; boundary="-"
103104
-------------------------->
104105
Status Code: OK
105106
-------------------------->
106107
107108
---
108109
Content-Type: application/json; charset=utf-8
109110
110-
{""data"":{""__typename"":""Query""}}
111+
{"data":{"__typename":"Query"}}
111112
-----
112-
");
113+
114+
""");
113115
}
114116

115117
[Theory]
@@ -249,14 +251,14 @@ public async Task UnsupportedAcceptHeaderValue()
249251
.Create()
250252
.Add(response)
251253
.MatchInline(
252-
@"Headers:
254+
"""
255+
Headers:
253256
Content-Type: application/graphql-response+json; charset=utf-8
254257
-------------------------->
255258
Status Code: BadRequest
256259
-------------------------->
257-
{""errors"":[{""message"":""Unable to parse the accept header value "
258-
+ @"`unsupported`."",""extensions"":{""code"":""HC0064"","
259-
+ @"""headerValue"":""unsupported""}}]}");
260+
{"errors":[{"message":"Unable to parse the accept header value `unsupported`.","extensions":{"code":"HC0064","headerValue":"unsupported"}}]}
261+
""");
260262
}
261263

262264
[Fact]
@@ -279,13 +281,14 @@ public async Task UnsupportedApplicationAcceptHeaderValue()
279281
.Create()
280282
.Add(response)
281283
.MatchInline(
282-
@"Headers:
284+
"""
285+
Headers:
283286
Content-Type: application/graphql-response+json; charset=utf-8
284287
-------------------------->
285288
Status Code: NotAcceptable
286289
-------------------------->
287-
{""errors"":[{""message"":""None of the `Accept` header values is supported."","
288-
+ @"""extensions"":{""code"":""HC0063""}}]}");
290+
{"errors":[{"message":"None of the `Accept` header values is supported.","extensions":{"code":"HC0063"}}]}
291+
""");
289292
}
290293

291294
[Theory]
@@ -313,24 +316,25 @@ public async Task DeferredQuery_Multipart(string? acceptHeader)
313316
.Create()
314317
.Add(response)
315318
.MatchInline(
316-
@"Headers:
319+
"""
320+
Headers:
317321
Cache-Control: no-cache
318-
Content-Type: multipart/mixed; boundary=""-""
322+
Content-Type: multipart/mixed; boundary="-"
319323
-------------------------->
320324
Status Code: OK
321325
-------------------------->
322326
323327
---
324328
Content-Type: application/json; charset=utf-8
325329
326-
{""data"":{},""hasNext"":true}
330+
{"data":{},"hasNext":true}
327331
---
328332
Content-Type: application/json; charset=utf-8
329333
330-
{""incremental"":[{""data"":{""__typename"":""Query""},"
331-
+ @"""path"":[]}],""hasNext"":false}
334+
{"incremental":[{"data":{"__typename":"Query"},"path":[]}],"hasNext":false}
332335
-----
333-
");
336+
337+
""");
334338
}
335339

336340
[Theory]
@@ -358,22 +362,23 @@ public async Task DeferredQuery_EventStream(string acceptHeader)
358362
.Create()
359363
.Add(response)
360364
.MatchInline(
361-
@"Headers:
365+
"""
366+
Headers:
362367
Cache-Control: no-cache
363368
Content-Type: text/event-stream; charset=utf-8
364369
-------------------------->
365370
Status Code: OK
366371
-------------------------->
367372
event: next
368-
data: {""data"":{},""hasNext"":true}
373+
data: {"data":{},"hasNext":true}
369374
370375
event: next
371-
data: {""incremental"":[{""data"":{""__typename"":""Query""},"
372-
+ @"""path"":[]}],""hasNext"":false}
376+
data: {"incremental":[{"data":{"__typename":"Query"},"path":[]}],"hasNext":false}
373377
374378
event: complete
375379
376-
");
380+
381+
""");
377382
}
378383

379384
[Fact]
@@ -397,12 +402,14 @@ public async Task DeferredQuery_NoStreamableAcceptHeader()
397402
.Create()
398403
.Add(response)
399404
.MatchInline(
400-
@"Headers:
405+
"""
406+
Headers:
401407
Content-Type: application/graphql-response+json; charset=utf-8
402408
-------------------------->
403409
Status Code: MethodNotAllowed
404410
-------------------------->
405-
{""errors"":[{""message"":""The specified operation kind is not allowed.""}]}");
411+
{"errors":[{"message":"The specified operation kind is not allowed."}]}
412+
""");
406413
}
407414

408415
[Fact]

0 commit comments

Comments
 (0)