Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,5 @@ makefile text
*.exe binary
*.pyc binary

# Verify support
# Verify
*.verified.txt text eol=lf working-tree-encoding=UTF-8
*.verified.xml text eol=lf working-tree-encoding=UTF-8
*.verified.json text eol=lf working-tree-encoding=UTF-8
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ _ReSharper.Caches
/artifacts

node_modules

# Verify
*.received.*
*.received/
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
[CA1720] Identifier 'xxx' contains type name
-->
<NoWarn>$(NoWarn);CA1200;CA1510;CA1716;CA1720</NoWarn>

<!-- Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken -->
<NoWarn>$(NoWarn);xUnit1051</NoWarn>
</PropertyGroup>

</Project>
6 changes: 2 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Namotion.Reflection" Version="3.4.2" />
<PackageVersion Include="NBench" Version="2.0.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="NodaTime" Version="3.2.2" />
<PackageVersion Include="NSwag.Core.Yaml" Version="14.0.0" />
<PackageVersion Include="Pro.NBench.xUnit" Version="2.0.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="Verify.XUnit" Version="30.5.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="Verify.XunitV3" Version="30.5.0" />
<PackageVersion Include="xunit.v3" Version="3.0.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.3" />
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>
Expand Down
10 changes: 10 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ indent_style = space
indent_size = 4
end_of_line = crlf
insert_final_newline = false

# Verify
[*.{received,verified}.{txt}]
charset = utf-8-bom
end_of_line = lf
indent_size = unset
indent_style = unset
insert_final_newline = false
tab_width = unset
trim_trailing_whitespace = false
48 changes: 0 additions & 48 deletions src/NJsonSchema.Benchmark/JsonInheritanceConverterBenchmarks.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NBench" />
<PackageReference Include="Pro.NBench.xUnit" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NJsonSchema.CodeGeneration.CSharp\NJsonSchema.CodeGeneration.CSharp.csproj" />
<ProjectReference Include="..\NJsonSchema.CodeGeneration.TypeScript\NJsonSchema.CodeGeneration.TypeScript.csproj" />
<ProjectReference Include="..\NJsonSchema.NewtonsoftJson\NJsonSchema.NewtonsoftJson.csproj" />
<ProjectReference Include="..\NJsonSchema.Tests\NJsonSchema.Tests.csproj" />
<ProjectReference Include="..\NJsonSchema\NJsonSchema.csproj" />
</ItemGroup>

Expand Down
19 changes: 0 additions & 19 deletions src/NJsonSchema.Benchmark/SchemaGenerationBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
using System.Runtime.Serialization;
using NBench;
using NJsonSchema.NewtonsoftJson.Generation;
using Pro.NBench.xUnit.XunitExtensions;
using Counter = NBench.Counter;

namespace NJsonSchema.Benchmark
{
public class SchemaGenerationBenchmarks
{
private Counter _counter;

[PerfSetup]
public void Setup(BenchmarkContext context)
{
_counter = context.GetCounter("Iterations");
}

[NBenchFact(Skip = "Can vary a lot when running on GitHub Actions")]
[PerfBenchmark(
NumberOfIterations = 3,
RunTimeMilliseconds = 1000,
RunMode = RunMode.Throughput,
TestMode = TestMode.Test)]
[CounterThroughputAssertion("Iterations", MustBe.GreaterThan, 100)]
public void GenerateSchema()
{
var schema = NewtonsoftJsonSchemaGenerator.FromType<Container>();
_counter.Increment();
}

public class SpecialTeacher : Teacher
Expand Down
28 changes: 1 addition & 27 deletions src/NJsonSchema.Benchmark/SerializationBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
using System.Reflection;
using NBench;
using Pro.NBench.xUnit.XunitExtensions;
using Counter = NBench.Counter;

[assembly: CollectionBehavior(DisableTestParallelization = true)]

namespace NJsonSchema.Benchmark
{
public class SerializationBenchmarks
{
private JsonSchema _schema;
private Counter _counter;
private string _json;

[PerfSetup]
public void Setup(BenchmarkContext context)
public void Setup()
{
var executingAssembly = Assembly.GetExecutingAssembly();

Expand All @@ -26,41 +19,22 @@ public void Setup(BenchmarkContext context)
}

_schema = JsonSchema.FromJsonAsync(_json).Result;
_counter = context.GetCounter("Iterations");
}

/// <summary>
/// Ensure that we can serialise at least 200 times per second (5ms).
/// </summary>
[NBenchFact]
[PerfBenchmark(
Description = "Ensure serialization doesn't take too long",
NumberOfIterations = 3,
RunTimeMilliseconds = 1000,
RunMode = RunMode.Throughput,
TestMode = TestMode.Test)]
[CounterThroughputAssertion("Iterations", MustBe.GreaterThan, 200)]
public void ToJson()
{
_schema.ToJson();
_counter.Increment();
}

/// <summary>
/// Ensure that we can deserialise at least 200 times per second (5ms).
/// </summary>
[NBenchFact]
[PerfBenchmark(
Description = "Ensure deserialization doesn't take too long",
NumberOfIterations = 3,
RunTimeMilliseconds = 1000,
RunMode = RunMode.Throughput,
TestMode = TestMode.Test)]
[CounterThroughputAssertion("Iterations", MustBe.GreaterThan, 200)]
public void FromJson()
{
JsonSchema.FromJsonAsync(_json).GetAwaiter().GetResult();
_counter.Increment();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public async Task When_using_SystemTextJson_additionalProperties_schema_is_set_f
}

[Fact]
public async Task When_using_SystemTextJson_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base_class()
public async Task When_using_STJ_additionalProperties_schema_is_set_for_object_then_special_property_is_rendered_only_for_lowest_base()
{
var json =
@"{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Nullable>disable</Nullable>
<AnalysisLevel>latest-Minimal</AnalysisLevel>
<NoWarn>$(NoWarn);1591</NoWarn>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,8 +17,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Verify.XUnit" />
<PackageReference Include="xunit" />
<PackageReference Include="Verify.XunitV3" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public async Task When_generating_from_json_schema_property_is_optional_and_Gene
[InlineData("date-time")]
[InlineData("time")]
[InlineData("time-span")]
public async Task When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_not_set_then_CSharp_property(string format)
public async Task When_generating_from_json_schema_string_property_with_date_or_time_format(string format)
{
// Arrange
var schemaJson = @"
Expand Down Expand Up @@ -201,7 +201,7 @@ public async Task When_generating_from_json_schema_string_property_with_date_or_
[InlineData("date-time")]
[InlineData("time")]
[InlineData("time-span")]
public async Task When_generating_from_json_schema_string_property_with_date_or_time_format_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property(string format)
public async Task When_generating_property_with_datetime_format_is_optional_and_GenerateNullableOptionalProperties(string format)
{
// Arrange
var schemaJson = @"
Expand Down Expand Up @@ -245,8 +245,7 @@ public async Task When_generating_from_json_schema_string_property_with_date_or_
}

[Fact]
public async Task
When_generating_from_json_schema_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set_then_CSharp_property()
public async Task When_generating_string_property_with_reference_is_optional_and_GenerateNullableOptionalProperties_is_set()
{
// Arrange
var schemaJson = @"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
<NoWarn>$(NoWarn),1998,1591,618,IDE1006</NoWarn>
<Nullable>disable</Nullable>
<EnableNETAnalyzers>false</EnableNETAnalyzers>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Verify.XUnit" />
<PackageReference Include="xunit" />
<PackageReference Include="Verify.XunitV3" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public sealed class EmptyClassInheritingDictionary : Dictionary<string, object>
[InlineData(true, true)]
[InlineData(false, false)]
[InlineData(true, false)]
public async Task When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works(bool inlineNamedDictionaries, bool convertConstructorInterfaceData)
public async Task When_empty_class_inherits_from_dictionary_then_allOf_inheritance_still_works(bool inline, bool convert)
{
// Arrange
var schema = NewtonsoftJsonSchemaGenerator.FromType<MyContainer>();
Expand All @@ -36,8 +36,8 @@ public async Task When_empty_class_inherits_from_dictionary_then_allOf_inheritan
var generator = new TypeScriptGenerator(schema, new TypeScriptGeneratorSettings
{
TypeScriptVersion = 2.0m,
InlineNamedDictionaries = inlineNamedDictionaries,
ConvertConstructorInterfaceData = convertConstructorInterfaceData
InlineNamedDictionaries = inline,
ConvertConstructorInterfaceData = convert
});

// Act
Expand All @@ -49,7 +49,7 @@ public async Task When_empty_class_inherits_from_dictionary_then_allOf_inheritan
Assert.Empty(dschema.AllOf);
Assert.True(dschema.IsDictionary);

await VerifyHelper.Verify(code).UseParameters(inlineNamedDictionaries, convertConstructorInterfaceData);
await VerifyHelper.Verify(code).UseParameters(inline, convert);
TypeScriptCompiler.AssertCompile(code);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
<Nullable>disable</Nullable>
<AnalysisLevel>latest-Minimal</AnalysisLevel>
<NoWarn>$(NoWarn);1591</NoWarn>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Verify.XUnit" />
<PackageReference Include="xunit" />
<PackageReference Include="Verify.XunitV3" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />
</ItemGroup>

Expand Down
Loading