Skip to content

Commit

Permalink
Fix XamlDirective stack overflow exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasGoulet73 committed Jan 18, 2025
1 parent b08d70d commit 29cf39e
Showing 1 changed file with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ internal class MemberReflector : Reflector
private const DesignerSerializationVisibility VisibilityInvalid = (DesignerSerializationVisibility)int.MaxValue;
// VisibilityNone indicates the value was looked up, and wasn't present
private const DesignerSerializationVisibility VisibilityNone = (DesignerSerializationVisibility)(int.MaxValue - 1);
private static MemberReflector s_UnknownReflector;

// Lazy init: check NullableReference.IsSet to determine if these fields have been initialized
private NullableReference<string> _constructorArgument;
Expand Down Expand Up @@ -74,33 +73,29 @@ internal MemberReflector(XamlType type, XamlValueConverter<TypeConverter> typeCo
_valueSerializer.Value = null;
}

internal static MemberReflector UnknownReflector
internal static MemberReflector UnknownReflector { get; } = CreateUnknownReflector();

private static MemberReflector CreateUnknownReflector()
{
get
MemberReflector unknownReflector = new MemberReflector
{
if (s_UnknownReflector is null)
{
s_UnknownReflector = new MemberReflector
{
_designerSerializationVisibility = DesignerSerializationVisibility.Visible,
_memberBits = (int)BoolMemberBits.Default |
(int)BoolMemberBits.Unknown | (int)BoolMemberBits.AllValid
};

// Explicitly set all the nullable references so that IsSet is true
s_UnknownReflector._deferringLoader.Value = null;
s_UnknownReflector._getter.Value = null;
s_UnknownReflector._setter.Value = null;
s_UnknownReflector._typeConverter.Value = null;
s_UnknownReflector._valueSerializer.Value = null;

s_UnknownReflector.DependsOn = XamlType.EmptyList<XamlMember>.Value;
s_UnknownReflector.Invoker = XamlMemberInvoker.UnknownInvoker;
s_UnknownReflector.Type = XamlLanguage.Object;
}
_designerSerializationVisibility = DesignerSerializationVisibility.Visible,
_memberBits = (int)BoolMemberBits.Default |
(int)BoolMemberBits.Unknown | (int)BoolMemberBits.AllValid
};

return s_UnknownReflector;
}
// Explicitly set all the nullable references so that IsSet is true
unknownReflector._deferringLoader.Value = null;
unknownReflector._getter.Value = null;
unknownReflector._setter.Value = null;
unknownReflector._typeConverter.Value = null;
unknownReflector._valueSerializer.Value = null;

unknownReflector.DependsOn = XamlType.EmptyList<XamlMember>.Value;
unknownReflector.Invoker = XamlMemberInvoker.UnknownInvoker;
unknownReflector.Type = XamlLanguage.Object;

return unknownReflector;
}

// Lazy init and thread safety note: all implicit properties (i.e properties without backing
Expand Down

0 comments on commit 29cf39e

Please sign in to comment.