Skip to content

Commit 38a4a83

Browse files
committed
Move RuntimeTypeConverter out of pubternal namespace
1 parent fbc5766 commit 38a4a83

File tree

8 files changed

+30
-8
lines changed

8 files changed

+30
-8
lines changed

src/JsonApiDotNetCore.Annotations/Resources/Identifiable.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.ComponentModel.DataAnnotations.Schema;
2-
using JsonApiDotNetCore.Resources.Internal;
32

43
namespace JsonApiDotNetCore.Resources;
54

src/JsonApiDotNetCore.Annotations/Resources/Internal/RuntimeTypeConverter.cs renamed to src/JsonApiDotNetCore.Annotations/Resources/RuntimeTypeConverter.cs

+28-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@
33

44
#pragma warning disable AV1008 // Class should not be static
55

6-
namespace JsonApiDotNetCore.Resources.Internal;
6+
namespace JsonApiDotNetCore.Resources;
77

8+
/// <summary>
9+
/// Provides utilities regarding runtime types.
10+
/// </summary>
811
[PublicAPI]
912
public static class RuntimeTypeConverter
1013
{
1114
private const string ParseQueryStringsUsingCurrentCultureSwitchName = "JsonApiDotNetCore.ParseQueryStringsUsingCurrentCulture";
1215

16+
/// <summary>
17+
/// Converts the specified value to the specified type.
18+
/// </summary>
19+
/// <param name="value">
20+
/// The value to convert from.
21+
/// </param>
22+
/// <param name="type">
23+
/// The type to convert to.
24+
/// </param>
25+
/// <returns>
26+
/// The converted type, or <c>null</c> if <paramref name="value" /> is <c>null</c> and <paramref name="type" /> is a nullable type.
27+
/// </returns>
28+
/// <exception cref="FormatException">
29+
/// <paramref name="value" /> is not compatible with <paramref name="type" />.
30+
/// </exception>
1331
public static object? ConvertType(object? value, Type type)
1432
{
1533
ArgumentGuard.NotNull(type);
@@ -114,11 +132,20 @@ public static class RuntimeTypeConverter
114132
}
115133
}
116134

135+
/// <summary>
136+
/// Indicates whether the specified type is a nullable value type or a reference type.
137+
/// </summary>
117138
public static bool CanContainNull(Type type)
118139
{
119140
return !type.IsValueType || Nullable.GetUnderlyingType(type) != null;
120141
}
121142

143+
/// <summary>
144+
/// Gets the default value for the specified type.
145+
/// </summary>
146+
/// <returns>
147+
/// The default value, or <c>null</c> for nullable value types and reference types.
148+
/// </returns>
122149
public static object? GetDefaultValue(Type type)
123150
{
124151
return type.IsValueType ? Activator.CreateInstance(type) : null;

src/JsonApiDotNetCore/Queries/Parsing/FilterParser.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using JsonApiDotNetCore.QueryStrings.FieldChains;
88
using JsonApiDotNetCore.Resources;
99
using JsonApiDotNetCore.Resources.Annotations;
10-
using JsonApiDotNetCore.Resources.Internal;
1110

1211
namespace JsonApiDotNetCore.Queries.Parsing;
1312

src/JsonApiDotNetCore/Queries/QueryableBuilding/WhereClauseBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using JsonApiDotNetCore.Configuration;
55
using JsonApiDotNetCore.Errors;
66
using JsonApiDotNetCore.Queries.Expressions;
7+
using JsonApiDotNetCore.Resources;
78
using JsonApiDotNetCore.Resources.Annotations;
8-
using JsonApiDotNetCore.Resources.Internal;
99

1010
namespace JsonApiDotNetCore.Queries.QueryableBuilding;
1111

src/JsonApiDotNetCore/Resources/IdentifiableExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using JsonApiDotNetCore.Resources.Internal;
32

43
namespace JsonApiDotNetCore.Resources;
54

src/JsonApiDotNetCore/Serialization/Response/ResponseModelAdapter.cs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using JsonApiDotNetCore.QueryStrings;
1111
using JsonApiDotNetCore.Resources;
1212
using JsonApiDotNetCore.Resources.Annotations;
13-
using JsonApiDotNetCore.Resources.Internal;
1413
using JsonApiDotNetCore.Serialization.Objects;
1514

1615
namespace JsonApiDotNetCore.Serialization.Response;

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetFilterParser.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using JsonApiDotNetCore.Queries.Expressions;
22
using JsonApiDotNetCore.Queries.Parsing;
33
using JsonApiDotNetCore.Resources;
4-
using JsonApiDotNetCore.Resources.Internal;
54

65
namespace JsonApiDotNetCoreTests.IntegrationTests.QueryStrings.CustomFunctions.TimeOffset;
76

test/JsonApiDotNetCoreTests/UnitTests/TypeConversion/RuntimeTypeConverterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using FluentAssertions;
2-
using JsonApiDotNetCore.Resources.Internal;
2+
using JsonApiDotNetCore.Resources;
33
using Xunit;
44

55
namespace JsonApiDotNetCoreTests.UnitTests.TypeConversion;

0 commit comments

Comments
 (0)