Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CompareAttribute.cs
Go to the documentation of this file.
5
7
8[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
10{
11 public string OtherProperty { get; }
12
13 public string? OtherPropertyDisplayName { get; internal set; }
14
15 public override bool RequiresValidationContext => true;
16
17 [RequiresUnreferencedCode("The property referenced by 'otherProperty' may be trimmed. Ensure it is preserved.")]
19 : base(System.SR.CompareAttribute_MustMatch)
20 {
21 OtherProperty = otherProperty ?? throw new ArgumentNullException("otherProperty");
22 }
23
24 public override string FormatErrorMessage(string name)
25 {
26 return string.Format(CultureInfo.CurrentCulture, base.ErrorMessageString, name, OtherPropertyDisplayName ?? OtherProperty);
27 }
28
29 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern", Justification = "The ctor is marked with RequiresUnreferencedCode informing the caller to preserve the other property.")]
31 {
32 PropertyInfo runtimeProperty = validationContext.ObjectType.GetRuntimeProperty(OtherProperty);
33 if (runtimeProperty == null)
34 {
36 }
37 if (runtimeProperty.GetIndexParameters().Length != 0)
38 {
40 }
41 object value2 = runtimeProperty.GetValue(validationContext.ObjectInstance, null);
42 if (!object.Equals(value, value2))
43 {
44 if (OtherPropertyDisplayName == null)
45 {
47 }
48 string[] memberNames = ((validationContext.MemberName == null) ? null : new string[1] { validationContext.MemberName });
50 }
51 return null;
52 }
53
66}
override bool Equals([NotNullWhen(true)] object? obj)
Definition Attribute.cs:691
override? ValidationResult IsValid(object? value, ValidationContext validationContext)
static CultureInfo CurrentCulture
static IEnumerable< Attribute > GetCustomAttributes(this Assembly element)
static string Common_PropertyNotFound
Definition SR.cs:20
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string CompareAttribute_UnknownProperty
Definition SR.cs:24
Definition SR.cs:7