diff --git a/UniSky.Moderation/InterpretedLabelValueDefinition.cs b/UniSky.Moderation/InterpretedLabelValueDefinition.cs index c861b7f..8e3eb43 100644 --- a/UniSky.Moderation/InterpretedLabelValueDefinition.cs +++ b/UniSky.Moderation/InterpretedLabelValueDefinition.cs @@ -106,7 +106,7 @@ public InterpretedLabelValueDefinition(LabelValueDefinition def, LabelerViewDeta Locales = def.Locales != null ? [.. def.Locales] : []; } - public LabelerViewDetailed Detailed { get; } + public LabelerViewDetailed? Detailed { get; } public string Identifier { get; init; } public LabelSeverity Severity { get; init; } diff --git a/UniSky.Moderation/LabelModerationCause.cs b/UniSky.Moderation/LabelModerationCause.cs index c900f16..ab1d8cf 100644 --- a/UniSky.Moderation/LabelModerationCause.cs +++ b/UniSky.Moderation/LabelModerationCause.cs @@ -9,12 +9,12 @@ public LabelModerationCause() : base() Type = ModerationCauseType.Label; } - public Label Label { get; internal set; } - public InterpretedLabelValueDefinition LabelDef { get; internal set; } - public LabelTarget Target { get; internal set; } - public LabelPreference Setting { get; internal set; } - public ModerationBehavior Behavior { get; internal set; } - public bool NoOverride { get; internal set; } + public required Label Label { get; set; } + public required InterpretedLabelValueDefinition LabelDef { get; set; } + public required LabelTarget Target { get; set; } + public required LabelPreference Setting { get; set; } + public required ModerationBehavior Behavior { get; set; } + public required bool NoOverride { get; set; } public override string ToString() { diff --git a/UniSky.Moderation/ModerationCause.cs b/UniSky.Moderation/ModerationCause.cs index 36e568f..b7d23c6 100644 --- a/UniSky.Moderation/ModerationCause.cs +++ b/UniSky.Moderation/ModerationCause.cs @@ -2,9 +2,9 @@ public class ModerationCause { - public ModerationCauseType Type { get; internal set; } - public ModerationCauseSource Source { get; internal set; } - public byte Priority { get; internal set; } + public required ModerationCauseType Type { get; set; } + public required ModerationCauseSource Source { get; set; } + public required byte Priority { get; set; } public bool Downgraded { get; internal set; } public override string ToString() diff --git a/UniSky.Moderation/ModerationCauseSource.cs b/UniSky.Moderation/ModerationCauseSource.cs index 5adb738..a1b6123 100644 --- a/UniSky.Moderation/ModerationCauseSource.cs +++ b/UniSky.Moderation/ModerationCauseSource.cs @@ -6,8 +6,8 @@ namespace UniSky.Moderation; public class ModerationCauseSource { public ModerationCauseSourceType Type { get; internal set; } - public ListViewBasic List { get; internal set; } - public ATDid Labeler { get; internal set; } + public ListViewBasic? List { get; internal set; } + public ATDid? Labeler { get; internal set; } public override string ToString() { diff --git a/UniSky.Moderation/ModerationDecision.cs b/UniSky.Moderation/ModerationDecision.cs index 7d497c4..a3f2e65 100644 --- a/UniSky.Moderation/ModerationDecision.cs +++ b/UniSky.Moderation/ModerationDecision.cs @@ -356,6 +356,7 @@ public ModerationDecision AddLabel(LabelTarget target, Label label, ModerationOp this.causes.Add(new LabelModerationCause() { + Type = ModerationCauseType.Label, Source = isSelf || labeler == null ? new ModerationCauseSource() { Type = ModerationCauseSourceType.User } : new ModerationCauseSource() { Type = ModerationCauseSourceType.Labeler, Labeler = labeler.Did }, diff --git a/UniSky.Moderation/Polyfill/IsExternalInit.cs b/UniSky.Moderation/Polyfill/IsExternalInit.cs deleted file mode 100644 index 9916537..0000000 --- a/UniSky.Moderation/Polyfill/IsExternalInit.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.ComponentModel; - -namespace System.Runtime.CompilerServices; - -[EditorBrowsable(EditorBrowsableState.Never)] -public class IsExternalInit { } \ No newline at end of file diff --git a/UniSky.Moderation/Polyfill/Polyfill.cs b/UniSky.Moderation/Polyfill/Polyfill.cs new file mode 100644 index 0000000..5c5adee --- /dev/null +++ b/UniSky.Moderation/Polyfill/Polyfill.cs @@ -0,0 +1,58 @@ +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; + +namespace System.Runtime.CompilerServices +{ + + [EditorBrowsable(EditorBrowsableState.Never)] + [ExcludeFromCodeCoverage] + internal class IsExternalInit { } + + [AttributeUsage( + AttributeTargets.Class | + AttributeTargets.Struct | + AttributeTargets.Field | + AttributeTargets.Property, + AllowMultiple = false, + Inherited = false)] + [EditorBrowsable(EditorBrowsableState.Never)] + [ExcludeFromCodeCoverage] + internal sealed class RequiredMemberAttribute : Attribute { } + + /// + /// Indicates that compiler support for a particular feature is required for the location where this attribute is applied. + /// + [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] + [ExcludeFromCodeCoverage] + internal sealed class CompilerFeatureRequiredAttribute : Attribute + { + /// + /// Creates a new instance of the type. + /// + /// The name of the feature to indicate. + public CompilerFeatureRequiredAttribute(string featureName) + { + FeatureName = featureName; + } + + /// + /// The name of the compiler feature. + /// + public string FeatureName { get; } + + /// + /// If true, the compiler can choose to allow access to the location where this attribute is applied if it does not understand . + /// + public bool IsOptional { get; set; } + + /// + /// The used for the ref structs C# feature. + /// + public const string RefStructs = nameof(RefStructs); + + /// + /// The used for the required members C# feature. + /// + public const string RequiredMembers = nameof(RequiredMembers); + } +} \ No newline at end of file