From 4f7c1a0b7636abef1772a14a5dc239464c9d5578 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 26 Jun 2020 15:03:28 +1000 Subject: [PATCH] Enable nullability in AxisSpec and related types --- .../Base Implementations/Axes/AxisConstraint.cs | 6 ++++-- .../Base Implementations/Axes/AxisDict.cs | 2 ++ .../Base Implementations/Axes/AxisPairOrientation.cs | 2 ++ .../Base Implementations/Axes/AxisSpec.cs | 8 +++++--- .../Base Implementations/Axes/CircularAxisConstraint.cs | 4 +++- .../Base Implementations/Axes/NoOpAxisConstraint.cs | 6 ++++-- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisConstraint.cs b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisConstraint.cs index adeed4e5fc..78c5ea606f 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisConstraint.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisConstraint.cs @@ -1,9 +1,11 @@ +#nullable enable + namespace BizHawk.Emulation.Common { public interface AxisConstraint { - public string Class { get; } + public string? Class { get; } - public string PairedAxis { get; } + public string? PairedAxis { get; } } } diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisDict.cs b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisDict.cs index 88d3577762..e1b2d2633c 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisDict.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisDict.cs @@ -1,3 +1,5 @@ +#nullable enable + using System.Collections; using System.Collections.Generic; diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisPairOrientation.cs b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisPairOrientation.cs index 89c5808fcc..4410bb19bc 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisPairOrientation.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisPairOrientation.cs @@ -1,3 +1,5 @@ +#nullable enable + namespace BizHawk.Emulation.Common { /// represents the direction of (+, +) diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisSpec.cs b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisSpec.cs index 79767e4c11..491a1f3a56 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisSpec.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Axes/AxisSpec.cs @@ -1,3 +1,5 @@ +#nullable enable + using System; using BizHawk.Common; @@ -11,7 +13,7 @@ namespace BizHawk.Emulation.Common /// For instance, a N64 controller's analog range is actually larger than the amount allowed by the plastic that artificially constrains it to lower values /// Axis constraints provide a way to technically allow the full range but have a user option to constrain down to typical values that a real control would have /// - public readonly AxisConstraint Constraint; + public readonly AxisConstraint? Constraint; public Range FloatRange => ((float) Min).RangeTo(Max); @@ -27,11 +29,11 @@ namespace BizHawk.Emulation.Common public int Min => Range.Start; - public string PairedAxis => Constraint?.PairedAxis; + public string? PairedAxis => Constraint?.PairedAxis; public readonly Range Range; - public AxisSpec(Range range, int mid, bool isReversed = false, AxisConstraint constraint = null) + public AxisSpec(Range range, int mid, bool isReversed = false, AxisConstraint? constraint = null) { Constraint = constraint; IsReversed = isReversed; diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Axes/CircularAxisConstraint.cs b/src/BizHawk.Emulation.Common/Base Implementations/Axes/CircularAxisConstraint.cs index 6d9920093b..1300b9e397 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Axes/CircularAxisConstraint.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Axes/CircularAxisConstraint.cs @@ -1,10 +1,12 @@ +#nullable enable + using System; namespace BizHawk.Emulation.Common { public sealed class CircularAxisConstraint : AxisConstraint { - public string Class { get; } + public string? Class { get; } private readonly float Magnitude; diff --git a/src/BizHawk.Emulation.Common/Base Implementations/Axes/NoOpAxisConstraint.cs b/src/BizHawk.Emulation.Common/Base Implementations/Axes/NoOpAxisConstraint.cs index 5c4b278aea..773d3f6301 100644 --- a/src/BizHawk.Emulation.Common/Base Implementations/Axes/NoOpAxisConstraint.cs +++ b/src/BizHawk.Emulation.Common/Base Implementations/Axes/NoOpAxisConstraint.cs @@ -1,10 +1,12 @@ +#nullable enable + namespace BizHawk.Emulation.Common { public sealed class NoOpAxisConstraint : AxisConstraint { - public string Class { get; } = null; + public string? Class { get; } = null; - public string PairedAxis { get; } + public string? PairedAxis { get; } public NoOpAxisConstraint(string pairedAxis) => PairedAxis = pairedAxis; }