Skip to content

Commit

Permalink
Cleanup pre-processor directives (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Oct 2, 2023
1 parent d6f0d01 commit ebd165d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public async Task When_schema_contains_discriminator_and_inheritance_hierarchy_t
Assert.Contains("this._discriminator = \"Dog\"", code);
}

#if NETCORE
#if !NETFRAMEWORK
[Fact]
#else
[Fact(Skip = "Dynamic compilation doesn't work for NET 4.6.1")]
Expand Down
2 changes: 1 addition & 1 deletion src/NJsonSchema.Tests/Generation/ArrayGenerationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task When_class_inherits_from_list_then_schema_is_inlined_and_type_
Assert.NotNull(schema.Definitions["SomeModelCollectionResponse"].Item);
}

#if NET5_0
#if !NETFRAMEWORK

public class ClassWithAsyncEnumerable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task When_using_JsonInheritanceAttribute_and_SystemTextJson_then_sc
},", data);
}

#if !NET462
#if !NETFRAMEWORK

public class Apple2 : Fruit2
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#if !net462
#if !NETFRAMEWORK

using System.Linq;
using Newtonsoft.Json.Converters;
using NJsonSchema.Generation;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

using NJsonSchema.Generation;

using Xunit;

namespace NJsonSchema.Tests.Generation.SystemTextJson
Expand Down
2 changes: 0 additions & 2 deletions src/NJsonSchema/JsonPathUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ public static string GetJsonPath(object rootObject, object searchedObject, ICont

var type = obj.GetType();
if (type == typeof(string)
#if !NETSTANDARD1_0
|| type.IsPrimitive
|| type.IsEnum
#endif
|| type == typeof(JValue)
|| checkedObjects.Contains(obj)
)
Expand Down
5 changes: 0 additions & 5 deletions src/NJsonSchema/JsonSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,8 @@ public static Task<JsonSchema> FromFileAsync(string filePath, CancellationToken
/// <exception cref="NotSupportedException">The System.IO.File API is not available on this platform.</exception>
public static Task<JsonSchema> FromFileAsync(string filePath, Func<JsonSchema, JsonReferenceResolver> referenceResolverFactory, CancellationToken cancellationToken = default)
{
#if !NETSTANDARD1_0
using var stream = File.OpenRead(filePath);
return FromJsonAsync(stream, filePath, referenceResolverFactory, cancellationToken);
#else
var json = DynamicApis.FileReadAllText(filePath);
return FromJsonAsync(json, filePath, referenceResolverFactory, cancellationToken);
#endif
}

/// <summary>Loads a JSON Schema from a given URL (only available in .NET 4.x).</summary>
Expand Down

0 comments on commit ebd165d

Please sign in to comment.