Skip to content

Commit

Permalink
better publicizing reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnemeti committed Jan 26, 2023
1 parent 7bd740c commit 4849e13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sarcasm/Publicizing/PublicizerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static class PublicizerExtensions
{
private static readonly Func<StringLiteral, IReadOnlyList<object>> _GetField__subtypes =
MemberInfoHelpers.CreateGetFuncByExpression<StringLiteral, IReadOnlyList<object>>(
typeof(StringLiteral).GetField("_subtypes", BindingFlags.Instance | BindingFlags.NonPublic)
typeof(StringLiteral).GetField("_subtypes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
);

public static IEnumerable<StringSubTypeProxy> GetPrivate_subtypes(this StringLiteral stringLiteral) =>
Expand Down
10 changes: 5 additions & 5 deletions Sarcasm/Publicizing/StringSubTypeProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ namespace Sarcasm.Publicizing
{
internal class StringSubTypeProxy
{
private static readonly Type _StringSubType_Type = typeof(StringLiteral).GetNestedType("StringSubType", BindingFlags.NonPublic);
private static readonly Type _StringSubType_Type = typeof(StringLiteral).GetNestedType("StringSubType", BindingFlags.Public | BindingFlags.NonPublic);

private static readonly Func<object, string> _GetField_Start =
MemberInfoHelpers.CreateGetFuncByExpression<object, string>(_StringSubType_Type.GetField("Start", BindingFlags.Instance | BindingFlags.Public));
MemberInfoHelpers.CreateGetFuncByExpression<object, string>(_StringSubType_Type.GetField("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));

private static readonly Func<object, string> _GetField_End =
MemberInfoHelpers.CreateGetFuncByExpression<object, string>(_StringSubType_Type.GetField("End", BindingFlags.Instance | BindingFlags.Public));
MemberInfoHelpers.CreateGetFuncByExpression<object, string>(_StringSubType_Type.GetField("End", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));

private static readonly Func<object, StringOptions> _GetField_Flags =
MemberInfoHelpers.CreateGetFuncByExpression<object, StringOptions>(_StringSubType_Type.GetField("Flags", BindingFlags.Instance | BindingFlags.Public));
MemberInfoHelpers.CreateGetFuncByExpression<object, StringOptions>(_StringSubType_Type.GetField("Flags", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));

private static readonly Func<object, byte> _GetField_Index =
MemberInfoHelpers.CreateGetFuncByExpression<object, byte>(_StringSubType_Type.GetField("Index", BindingFlags.Instance | BindingFlags.Public));
MemberInfoHelpers.CreateGetFuncByExpression<object, byte>(_StringSubType_Type.GetField("Index", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));

public string Start => _GetField_Start(_stringSubType);
public string End => _GetField_End(_stringSubType);
Expand Down

0 comments on commit 4849e13

Please sign in to comment.