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 11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4- using Microsoft . AspNetCore . JsonPatch . SystemTextJson ;
5-
64namespace Microsoft . AspNetCore . OpenApi ;
75
86internal static class TypeExtensions
97{
8+ private const string JsonPatchDocumentNamespace = "Microsoft.AspNetCore.JsonPatch.SystemTextJson" ;
9+ private const string JsonPatchDocumentName = "JsonPatchDocument" ;
10+ private const string JsonPatchDocumentNameOfT = "JsonPatchDocument`1" ;
11+
1012 public static bool IsJsonPatchDocument ( this Type type )
1113 {
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.
1717 var modelType = type ;
1818
1919 while ( modelType != null && modelType != typeof ( object ) )
2020 {
21- if ( modelType . IsGenericType && modelType . GetGenericTypeDefinition ( ) == typeof ( JsonPatchDocument < > ) )
21+ if ( modelType . Namespace == JsonPatchDocumentNamespace &&
22+ ( modelType . Name == JsonPatchDocumentName || modelType . Name . StartsWith ( JsonPatchDocumentNameOfT , StringComparison . Ordinal ) ) )
2223 {
2324 return true ;
2425 }
Original file line number Diff line number Diff line change 1717 <Reference Include =" Microsoft.AspNetCore" />
1818 <Reference Include =" Microsoft.AspNetCore.Http.Abstractions" />
1919 <Reference Include =" Microsoft.AspNetCore.Http.Results" />
20- <Reference Include =" Microsoft.AspNetCore.JsonPatch.SystemTextJson" />
2120 <Reference Include =" Microsoft.AspNetCore.Mvc.ApiExplorer" />
2221 <Reference Include =" Microsoft.AspNetCore.Mvc.Core" />
2322 <Reference Include =" Microsoft.AspNetCore.Routing" />
You can’t perform that action at this time.
0 commit comments