Skip to content

Commit 531ebd8

Browse files
committed
Additional self-review round
1 parent 45dd549 commit 531ebd8

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

Diff for: JsonApiDotNetCore.sln.DotSettings

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$, $NAME$);</s:String>
1515
<s:Int64 x:Key="/Default/CodeEditing/NullCheckPatterns/PatternTypeNamesToPriority/=JetBrains_002EReSharper_002EFeature_002EServices_002ECSharp_002ENullChecking_002ETraceAssertPattern/@EntryIndexedValue">50</s:Int64>
1616
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/PropagateAnnotations/@EntryValue">False</s:Boolean>
1717
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=swagger_002Ejson/@EntryIndexedValue">True</s:Boolean>
18-
19-
20-
2118
<s:String x:Key="/Default/CodeInspection/GeneratedCode/GeneratedFileMasks/=swagger_002Ejson/@EntryIndexedValue">swagger.json</s:String>
2219
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
2320
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/IdentifierHighlightingEnabled/@EntryValue">True</s:Boolean>

Diff for: src/JsonApiDotNetCore.OpenApi.Client/ApiException.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ internal class ApiException : Exception
1616
public IReadOnlyDictionary<string, IEnumerable<string>> Headers { get; }
1717

1818
public ApiException(string message, int statusCode, string? response, IReadOnlyDictionary<string, IEnumerable<string>> headers, Exception innerException)
19-
: base(
20-
message + "\n\nStatus: " + statusCode + "\nResponse: \n" +
21-
(response == null ? "(null)" : response[..(response.Length >= 512 ? 512 : response.Length)]), innerException)
19+
: base($"{message}\n\nStatus: {statusCode}\nResponse: \n{response ?? "(null)"}", innerException)
2220
{
2321
StatusCode = statusCode;
2422
Response = response;

Diff for: src/JsonApiDotNetCore.OpenApi/StringExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace JsonApiDotNetCore.OpenApi;
44

55
internal static class StringExtensions
66
{
7-
private static readonly Regex Pattern = new("(?:^|-|_| +)(.)", RegexOptions.Compiled);
7+
private static readonly Regex PatternForPascalCaseConversion = new("(?:^|-|_| +)(.)", RegexOptions.Compiled);
88

99
public static string ToPascalCase(this string source)
1010
{
11-
return Pattern.Replace(source, match => match.Groups[1].Value.ToUpper());
11+
return PatternForPascalCaseConversion.Replace(source, match => match.Groups[1].Value.ToUpper());
1212
}
1313
}

Diff for: test/OpenApiTests/JsonElementExtensions.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ public static ReferenceSchemaIdContainer ShouldBeReferenceSchemaId(this JsonElem
3535
string referenceSchemaId = jsonElementValue.Split('/').Last();
3636
referenceSchemaId.Should().Be(value);
3737

38-
return new ReferenceSchemaIdContainer
39-
{
40-
ReferenceSchemaId = value
41-
};
38+
return new ReferenceSchemaIdContainer(value);
4239
}
4340

4441
public sealed class ReferenceSchemaIdContainer
4542
{
46-
internal string ReferenceSchemaId { get; init; } = null!;
43+
public string ReferenceSchemaId { get; }
44+
45+
public ReferenceSchemaIdContainer(string referenceSchemaId)
46+
{
47+
ReferenceSchemaId = referenceSchemaId;
48+
}
4749
}
4850

4951
public sealed class JsonElementAssertions : JsonElementAssertions<JsonElementAssertions>

Diff for: test/OpenApiTests/OpenApiTestSuite.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ public abstract class OpenApiTestSuite<TStartup, TDbContext> : IClassFixture<Ope
1010
where TDbContext : DbContext
1111
{
1212
private readonly OpenApiTestContext<TStartup, TDbContext> _testContext;
13-
private readonly bool _shouldWriteDocumentToDisk;
13+
private readonly bool _isFirstTestRunInTestSuite;
1414

1515
protected OpenApiTestSuite(OpenApiTestContext<TStartup, TDbContext> testContext)
1616
{
1717
_testContext = testContext;
18-
_shouldWriteDocumentToDisk = !testContext.LazyDocument.IsValueCreated;
18+
_isFirstTestRunInTestSuite = !testContext.LazyDocument.IsValueCreated;
1919
}
2020

2121
protected void UseController<TController>()
2222
where TController : ControllerBase
2323
{
24-
if (!_testContext.LazyDocument.IsValueCreated)
24+
if (_isFirstTestRunInTestSuite)
2525
{
2626
_testContext.UseController<TController>();
2727
}
@@ -31,7 +31,7 @@ protected async Task<JsonElement> GetDocumentAsync()
3131
{
3232
JsonElement document = await _testContext.LazyDocument.Value;
3333

34-
if (_shouldWriteDocumentToDisk)
34+
if (_isFirstTestRunInTestSuite)
3535
{
3636
await WriteSwaggerDocumentToFileAsync(document);
3737
}
@@ -51,6 +51,7 @@ private static string GetTestSuitePath()
5151
{
5252
string pathToSolutionTestDirectory = Path.Combine(Environment.CurrentDirectory, "../../../../");
5353
pathToSolutionTestDirectory = Path.GetFullPath(pathToSolutionTestDirectory);
54+
5455
string pathToCurrentNamespaceRelativeToTestDirectory = Path.Combine(typeof(TStartup).Namespace!.Split('.'));
5556

5657
return Path.Join(pathToSolutionTestDirectory, pathToCurrentNamespaceRelativeToTestDirectory);

0 commit comments

Comments
 (0)