Skip to content

Commit fae4c39

Browse files
committed
ReflectionBridgeExtensions: Make internals visible to Json lib
1 parent 1122bc9 commit fae4c39

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.Signed.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<!-- Enable strong name signing -->
1111
<PropertyGroup>
12+
<DefineConstants>SIGNED</DefineConstants>
1213
<SignAssembly>true</SignAssembly>
1314
<AssemblyOriginatorKeyFile>$(MSBuildProjectDirectory)\..\UnitsNet.snk</AssemblyOriginatorKeyFile>
1415
</PropertyGroup>

UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020
// THE SOFTWARE.
2121

22+
using System.Runtime.CompilerServices;
2223
using System;
2324
using System.Collections.Generic;
24-
//using System.Linq;
2525
using System.Reflection;
2626

27+
#if SIGNED
28+
[assembly: InternalsVisibleTo("UnitsNet.Serialization.JsonNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010089abdcb0025f7d1c4c766686dd852b978ca5bb9fd80bba9d3539e8399b01170ae0ea10c0c3baa301b1d13090d5aff770532de00c88b67c4b24669fde7f9d87218f1c6c073a09016cbb2f87119b94227c2301f4e2a096043e30f7c47c872bbd8e0b80d924952e6b36990f13f847e83e9efb107ec2121fe39d7edaaa4e235af8c4")]
29+
#else
30+
[assembly: InternalsVisibleTo("UnitsNet.Serialization.JsonNet")]
31+
#endif
32+
2733
// Based on
2834
// https://github.com/StefH/ReflectionBridge/blob/c1e34e57fe3fc93507e83d5cebc1677396645397/ReflectionBridge/src/ReflectionBridge/Extensions/ReflectionBridgeExtensions.cs
2935
// MIT license
@@ -205,8 +211,18 @@ internal static bool IsValueType(this Type type)
205211
//#endif
206212
// }
207213

214+
internal static PropertyInfo GetPropety(this Type type, string name)
215+
{
216+
#if (NET40 || NET35 || NET20 || SILVERLIGHT)
217+
return type.GetProperty(name);
218+
219+
#else
220+
return type.GetTypeInfo().GetDeclaredProperty(name);
221+
#endif
222+
}
223+
208224
#if !(NET40 || NET35 || NET20 || SILVERLIGHT)
209-
// Ambiguous method conflict with GetMethods() name WindowsRuntimeComponent, so use GetDeclaredMethods() instead
225+
// Ambiguous method conflict with GetMethods() name when targeting WindowsRuntimeComponent, so use GetDeclaredMethods() instead
210226
internal static IEnumerable<MethodInfo> GetDeclaredMethods(this Type someType)
211227
{
212228
Type t = someType;
@@ -245,7 +261,7 @@ internal static IEnumerable<MethodInfo> GetDeclaredMethods(this Type someType)
245261
// return type.GetTypeInfo().GetCustomAttributes(attributeType, inherit).Cast<Attribute>().ToArray();
246262
// }
247263
#else
248-
// Ambiguous method conflict with GetMethods() name WindowsRuntimeComponent, so use GetDeclaredMethods() instead
264+
// Ambiguous method conflict with GetMethods() name WindowsRuntimeComponent, so use GetDeclaredMethods() instead
249265
internal static IEnumerable<MethodInfo> GetDeclaredMethods(this Type someType)
250266
{
251267
Type t = someType;
@@ -258,4 +274,4 @@ internal static IEnumerable<MethodInfo> GetDeclaredMethods(this Type someType)
258274
}
259275
#endif
260276
}
261-
}
277+
}

UnitsNet/UnitsNet.NetStandard10.Signed.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<!-- Enable strong name signing -->
1111
<PropertyGroup>
12+
<DefineConstants>SIGNED</DefineConstants>
1213
<SignAssembly>true</SignAssembly>
1314
<AssemblyOriginatorKeyFile>$(MSBuildProjectDirectory)\..\UnitsNet.snk</AssemblyOriginatorKeyFile>
1415
</PropertyGroup>

0 commit comments

Comments
 (0)