Skip to content

Commit 0175043

Browse files
committed
fix: remove dependency
1 parent 5954d85 commit 0175043

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/JsonApiDotNetCore/Internal/ResourceGraph.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq.Expressions;
55
using JsonApiDotNetCore.Internal.Contracts;
66
using JsonApiDotNetCore.Models;
7-
using Castle.DynamicProxy;
87

98
namespace JsonApiDotNetCore.Internal
109
{
@@ -14,10 +13,12 @@ namespace JsonApiDotNetCore.Internal
1413
public class ResourceGraph : IResourceGraph
1514
{
1615
private List<ResourceContext> Resources { get; }
16+
private Type ProxyInterface { get; }
1717

1818
public ResourceGraph(List<ResourceContext> resources)
1919
{
2020
Resources = resources;
21+
ProxyInterface = Type.GetType("Castle.DynamicProxy.IProxyTargetAccessor, Castle.Core");
2122
}
2223

2324
/// <inheritdoc />
@@ -128,10 +129,7 @@ private IEnumerable<IResourceField> Getter<T>(Expression<Func<T, dynamic>> selec
128129
$"For example: 'article => article.Title' or 'article => new {{ article.Title, article.PageCount }}'.");
129130
}
130131

131-
private bool IsDynamicProxy(Type resourceType)
132-
{
133-
return typeof(IProxyTargetAccessor).IsAssignableFrom(resourceType);
134-
}
132+
private bool IsDynamicProxy(Type resourceType) => ProxyInterface?.IsAssignableFrom(resourceType) ?? false;
135133

136134
private static Expression RemoveConvert(Expression expression)
137135
=> expression is UnaryExpression unaryExpression

src/JsonApiDotNetCore/JsonApiDotNetCore.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
<ItemGroup>
2424
<PackageReference Include="Ben.Demystifier" Version="0.1.6" />
25-
<PackageReference Include="Castle.Core" Version="4.4.1" />
2625
<PackageReference Include="Humanizer" Version="2.7.9" />
2726
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(EFCoreVersion)" />
2827
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />

test/UnitTests/UnitTests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<ItemGroup>
1717
<PackageReference Include="Bogus" Version="$(BogusVersion)" />
1818
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(EFCoreVersion)" />
19+
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="$(EFCoreVersion)" />
1920
<PackageReference Include="Moq" Version="$(MoqVersion)" />
2021
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
2122
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />

0 commit comments

Comments
 (0)