Skip to content

Commit

Permalink
Fix nullability warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
WamWooWam committed Jan 6, 2025
1 parent ba15ca3 commit 9a26a8a
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 18 deletions.
2 changes: 1 addition & 1 deletion UniSky.Moderation/InterpretedLabelValueDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
12 changes: 6 additions & 6 deletions UniSky.Moderation/LabelModerationCause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
6 changes: 3 additions & 3 deletions UniSky.Moderation/ModerationCause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions UniSky.Moderation/ModerationCauseSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions UniSky.Moderation/ModerationDecision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
6 changes: 0 additions & 6 deletions UniSky.Moderation/Polyfill/IsExternalInit.cs

This file was deleted.

58 changes: 58 additions & 0 deletions UniSky.Moderation/Polyfill/Polyfill.cs
Original file line number Diff line number Diff line change
@@ -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 { }

/// <summary>
/// Indicates that compiler support for a particular feature is required for the location where this attribute is applied.
/// </summary>
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="CompilerFeatureRequiredAttribute"/> type.
/// </summary>
/// <param name="featureName">The name of the feature to indicate.</param>
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}

/// <summary>
/// The name of the compiler feature.
/// </summary>
public string FeatureName { get; }

/// <summary>
/// If true, the compiler can choose to allow access to the location where this attribute is applied if it does not understand <see cref="FeatureName"/>.
/// </summary>
public bool IsOptional { get; set; }

/// <summary>
/// The <see cref="FeatureName"/> used for the ref structs C# feature.
/// </summary>
public const string RefStructs = nameof(RefStructs);

/// <summary>
/// The <see cref="FeatureName"/> used for the required members C# feature.
/// </summary>
public const string RequiredMembers = nameof(RequiredMembers);
}
}

0 comments on commit 9a26a8a

Please sign in to comment.