File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
- using Microsoft . AspNetCore . JsonPatch . SystemTextJson ;
5
-
6
4
namespace Microsoft . AspNetCore . OpenApi ;
7
5
8
6
internal static class TypeExtensions
9
7
{
8
+ private const string JsonPatchDocumentNamespace = "Microsoft.AspNetCore.JsonPatch.SystemTextJson" ;
9
+ private const string JsonPatchDocumentName = "JsonPatchDocument" ;
10
+ private const string JsonPatchDocumentNameOfT = "JsonPatchDocument`1" ;
11
+
10
12
public static bool IsJsonPatchDocument ( this Type type )
11
13
{
12
- if ( type . IsAssignableTo ( typeof ( JsonPatchDocument ) ) )
13
- {
14
- return true ;
15
- }
16
-
14
+ // We cannot depend on the actual runtime type as
15
+ // Microsoft.AspNetCore.JsonPatch.SystemTextJson is not
16
+ // AoT compatible so cannot be referenced by Microsoft.AspNetCore.OpenApi.
17
17
var modelType = type ;
18
18
19
19
while ( modelType != null && modelType != typeof ( object ) )
20
20
{
21
- if ( modelType . IsGenericType && modelType . GetGenericTypeDefinition ( ) == typeof ( JsonPatchDocument < > ) )
21
+ if ( modelType . Namespace == JsonPatchDocumentNamespace &&
22
+ ( modelType . Name == JsonPatchDocumentName || modelType . Name . StartsWith ( JsonPatchDocumentNameOfT , StringComparison . Ordinal ) ) )
22
23
{
23
24
return true ;
24
25
}
Original file line number Diff line number Diff line change 17
17
<Reference Include =" Microsoft.AspNetCore" />
18
18
<Reference Include =" Microsoft.AspNetCore.Http.Abstractions" />
19
19
<Reference Include =" Microsoft.AspNetCore.Http.Results" />
20
- <Reference Include =" Microsoft.AspNetCore.JsonPatch.SystemTextJson" />
21
20
<Reference Include =" Microsoft.AspNetCore.Mvc.ApiExplorer" />
22
21
<Reference Include =" Microsoft.AspNetCore.Mvc.Core" />
23
22
<Reference Include =" Microsoft.AspNetCore.Routing" />
You can’t perform that action at this time.
0 commit comments