Skip to content

Commit 0473dd1

Browse files
Merge pull request #99 from telerik/stoilov/fix-private-accessor
The static constructor of a type disrespects previously created arragements when triggered by the Telerik.JustMock.PrivateAccessor class
2 parents 2d75dda + 7e89778 commit 0473dd1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Telerik.JustMock/PrivateAccessor.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
JustMock Lite
3-
Copyright © 2010-2015,2018 Progress Software Corporation
3+
Copyright © 2010-2015,2018-2019 Progress Software Corporation
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -94,12 +94,20 @@ private PrivateAccessor(object instance, Type type)
9494
#if (!COREFX && !NETCORE)
9595
var realProxy = MockingProxy.GetRealProxy(instance);
9696
if (realProxy != null)
97+
{
9798
instance = realProxy.WrappedInstance;
99+
}
98100
#endif
99101
type = instance.GetType();
100102
}
101103
if (type.IsProxy() && type.BaseType != typeof(object))
104+
{
102105
type = type.BaseType;
106+
}
107+
108+
#if (!PORTABLE && !LITE_EDITION)
109+
Mock.Intercept(type);
110+
#endif
103111
});
104112

105113
this.instance = instance;
@@ -516,8 +524,8 @@ private static bool CheckReflectionPermission()
516524
#if (COREFX)
517525
return false;
518526
#else
519-
try
520-
{
527+
try
528+
{
521529
new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Demand();
522530
return true;
523531
}

0 commit comments

Comments
 (0)