Manual fixes to reduce warnings to zero

This commit is contained in:
Dean Herbert
2023-06-22 15:18:07 +09:00
parent 75ed421f60
commit 306465081f
36 changed files with 42 additions and 96 deletions

View File

@@ -51,7 +51,7 @@ namespace osu.Framework.Benchmarks
new CharacterGlyph(character, character, character, character, character, null),
new DummyRenderer().CreateTexture(1, 1));
public Task<ITexturedCharacterGlyph> GetAsync(string fontName, char character) => Task.Run(() => Get(fontName, character));
public Task<ITexturedCharacterGlyph?> GetAsync(string fontName, char character) => Task.Run<ITexturedCharacterGlyph?>(() => Get(fontName, character));
}
}
}

View File

@@ -25,9 +25,6 @@ namespace osu.Framework.Tests.Visual.UserInterface
{
restitutionBacking = value;
if (sim == null)
return;
foreach (var d in sim.Children)
d.Restitution = value;
sim.Restitution = value;
@@ -43,9 +40,6 @@ namespace osu.Framework.Tests.Visual.UserInterface
{
frictionBacking = value;
if (sim == null)
return;
foreach (var d in sim.Children)
d.FrictionCoefficient = value;
sim.FrictionCoefficient = value;

View File

@@ -12,7 +12,7 @@ namespace osu.Framework.Bindables
{
}
public override string ToString(string format, IFormatProvider formatProvider) => base.ToString(format ?? "0.0###", formatProvider);
public override string ToString(string? format, IFormatProvider formatProvider) => base.ToString(format ?? "0.0###", formatProvider);
protected override Bindable<double> CreateInstance() => new BindableDouble();
}

View File

@@ -12,7 +12,7 @@ namespace osu.Framework.Bindables
{
}
public override string ToString(string format, IFormatProvider formatProvider) => base.ToString(format ?? "0.0###", formatProvider);
public override string ToString(string? format, IFormatProvider formatProvider) => base.ToString(format ?? "0.0###", formatProvider);
protected override Bindable<float> CreateInstance() => new BindableFloat();
}

View File

@@ -55,7 +55,7 @@ namespace osu.Framework.Development
public static bool LogPerformanceIssues { get; internal set; }
// https://stackoverflow.com/a/2186634
private static bool isDebugAssembly(Assembly assembly) => assembly?.GetCustomAttributes(false).OfType<DebuggableAttribute>().Any(da => da.IsJITTrackingEnabled) ?? false;
private static bool isDebugAssembly(Assembly? assembly) => assembly?.GetCustomAttributes(false).OfType<DebuggableAttribute>().Any(da => da.IsJITTrackingEnabled) ?? false;
/// <summary>
/// Gets the entry assembly, or calling assembly otherwise.

View File

@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Performance;
namespace osu.Framework.Graphics.Containers
@@ -136,7 +137,7 @@ namespace osu.Framework.Graphics.Containers
public void Dispose()
{
if (Drawable != null)
if (Drawable.IsNotNull())
Drawable.LifetimeChanged -= drawableLifetimeChanged;
}
}

View File

@@ -36,7 +36,7 @@ namespace osu.Framework.Graphics.Containers.Markdown
var text = parentTextComponent.CreateSpriteText();
text.Colour = new Color4(255, 0, 0, 255);
text.Font = text.Font.With(size: 21);
text.Text = markdownObject?.GetType() + " Not implemented.";
text.Text = markdownObject.GetType() + " Not implemented.";
return text;
}
}

View File

@@ -8,7 +8,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Threading;
using System;
using JetBrains.Annotations;
using osu.Framework.Bindables;
namespace osu.Framework.Graphics
@@ -249,7 +248,7 @@ namespace osu.Framework.Graphics
/// Smoothly adjusts the value of a <see cref="Bindable{TValue}"/> over time.
/// </summary>
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public static TransformSequence<T> TransformBindableTo<T, TValue>(this TransformSequence<T> t, [NotNull] Bindable<TValue> bindable, TValue newValue, double duration = 0,
public static TransformSequence<T> TransformBindableTo<T, TValue>(this TransformSequence<T> t, Bindable<TValue> bindable, TValue newValue, double duration = 0,
Easing easing = Easing.None)
where T : class, ITransformable
=> t.TransformBindableTo(bindable, newValue, duration, new DefaultEasingFunction(easing));
@@ -487,7 +486,7 @@ namespace osu.Framework.Graphics
/// Smoothly adjusts the value of a <see cref="Bindable{TValue}"/> over time.
/// </summary>
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public static TransformSequence<T> TransformBindableTo<T, TValue, TEasing>(this TransformSequence<T> t, [NotNull] Bindable<TValue> bindable, TValue newValue, double duration, TEasing easing)
public static TransformSequence<T> TransformBindableTo<T, TValue, TEasing>(this TransformSequence<T> t, Bindable<TValue> bindable, TValue newValue, double duration, TEasing easing)
where T : class, ITransformable
where TEasing : IEasingFunction
=> t.Append(o => o.TransformBindableTo(bindable, newValue, duration, easing));

View File

@@ -15,12 +15,8 @@ namespace osu.Framework.Graphics.UserInterface
{
public LocalisableString Text
{
get => SpriteText?.Text ?? default;
set
{
if (SpriteText != null)
SpriteText.Text = value;
}
get => SpriteText.Text;
set => SpriteText.Text = value;
}
public Color4 BackgroundColour

View File

@@ -18,7 +18,7 @@ namespace osu.Framework.Graphics.UserInterface
/// <summary>
/// The <see cref="Action"/> that is performed when this <see cref="MenuItem"/> is clicked.
/// </summary>
public readonly Bindable<Action> Action = new Bindable<Action>();
public readonly Bindable<Action?> Action = new Bindable<Action?>();
/// <summary>
/// A list of items which are to be displayed in a sub-menu originating from this <see cref="MenuItem"/>.
@@ -48,7 +48,7 @@ namespace osu.Framework.Graphics.UserInterface
/// </summary>
/// <param name="text">The text to display.</param>
/// <param name="action">The <see cref="Action"/> to perform when clicked.</param>
public MenuItem(LocalisableString text, Action action)
public MenuItem(LocalisableString text, Action? action)
: this(text)
{
Action.Value = action;

View File

@@ -3,13 +3,12 @@
#nullable disable
using osu.Framework.Graphics.Textures;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using osu.Framework.Logging;
using System.Collections.Concurrent;
using JetBrains.Annotations;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Textures;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Text;
@@ -131,7 +130,6 @@ namespace osu.Framework.IO.Stores
base.RemoveStore(store);
}
[CanBeNull]
public ITexturedCharacterGlyph Get(string fontName, char character)
{
var key = (fontName, character);

View File

@@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
@@ -118,7 +118,6 @@ namespace osu.Framework.IO.Stores
return $@"{AssetName}_{page.ToString().PadLeft((Font.Pages.Count - 1).ToString().Length, '0')}.png";
}
[CanBeNull]
public CharacterGlyph Get(char character)
{
if (Font == null)

View File

@@ -36,7 +36,7 @@ namespace osu.Framework.IO.Stores
/// </summary>
/// <param name="character">The character to retrieve the <see cref="CharacterGlyph"/> for.</param>
/// <returns>The <see cref="CharacterGlyph"/> containing associated spacing information for <paramref name="character"/>.</returns>
CharacterGlyph Get(char character);
CharacterGlyph? Get(char character);
/// <summary>
/// Retrieves the kerning for a pair of characters.

View File

@@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Graphics;
using osu.Framework.Input.States;
@@ -15,8 +14,7 @@ namespace osu.Framework.Input.Events
/// <summary>
/// The <see cref="Drawable"/> that has lost focus, or <c>null</c> if nothing was previously focused.
/// </summary>
[CanBeNull]
public readonly Drawable PreviouslyFocused;
public readonly Drawable? PreviouslyFocused;
public FocusEvent(InputState state, Drawable previouslyFocused)
: base(state)

View File

@@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Graphics;
using osu.Framework.Input.States;
@@ -15,8 +14,7 @@ namespace osu.Framework.Input.Events
/// <summary>
/// The <see cref="Drawable"/> that will gain focus, or <c>null</c> if nothing will gain focus.
/// </summary>
[CanBeNull]
public readonly Drawable NextFocused;
public readonly Drawable? NextFocused;
public FocusLostEvent(InputState state, Drawable nextFocused)
: base(state)

View File

@@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Input.States;
@@ -27,7 +26,7 @@ namespace osu.Framework.Input.Events
/// </summary>
public float Delta => Axis.Value - LastValue;
public JoystickAxisMoveEvent([NotNull] InputState state, JoystickAxis axis, float lastValue)
public JoystickAxisMoveEvent(InputState state, JoystickAxis axis, float lastValue)
: base(state)
{
LastValue = lastValue;

View File

@@ -3,14 +3,13 @@
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Input.States;
namespace osu.Framework.Input.Events
{
public abstract class JoystickEvent : UIEvent
{
protected JoystickEvent([NotNull] InputState state)
protected JoystickEvent(InputState state)
: base(state)
{
}

View File

@@ -1,14 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Input.States;
namespace osu.Framework.Input.Events
{
public class MidiDownEvent : MidiEvent
{
public MidiDownEvent([NotNull] InputState state, MidiKey key, byte velocity)
public MidiDownEvent(InputState state, MidiKey key, byte velocity)
: base(state, key, velocity)
{
}

View File

@@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using JetBrains.Annotations;
using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Input.States;
@@ -28,7 +27,7 @@ namespace osu.Framework.Input.Events
/// </summary>
public IEnumerable<MidiKey> PressedKeys => CurrentState.Midi.Keys;
protected MidiEvent([NotNull] InputState state, MidiKey key, byte velocity)
protected MidiEvent(InputState state, MidiKey key, byte velocity)
: base(state)
{
Key = key;

View File

@@ -1,14 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Input.States;
namespace osu.Framework.Input.Events
{
public class MidiUpEvent : MidiEvent
{
public MidiUpEvent([NotNull] InputState state, MidiKey key)
public MidiUpEvent(InputState state, MidiKey key)
: base(state, key, 0)
{
}

View File

@@ -2,14 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using JetBrains.Annotations;
using osu.Framework.Input.States;
namespace osu.Framework.Input.Events
{
public abstract class TabletEvent : UIEvent
{
protected TabletEvent([NotNull] InputState state)
protected TabletEvent(InputState state)
: base(state)
{
}

View File

@@ -17,12 +17,7 @@ namespace osu.Framework.Input
protected override Drawable HandleButtonDown(InputState state, List<Drawable> targets) => PropagateButtonEvent(targets, new JoystickPressEvent(state, Button));
protected override void HandleButtonUp(InputState state, List<Drawable> targets)
{
if (targets == null)
return;
protected override void HandleButtonUp(InputState state, List<Drawable> targets) =>
PropagateButtonEvent(targets, new JoystickReleaseEvent(state, Button));
}
}
}

View File

@@ -31,12 +31,7 @@ namespace osu.Framework.Input
protected override Drawable HandleButtonDown(InputState state, List<Drawable> targets) => PropagateButtonEvent(targets, new KeyDownEvent(state, Button));
protected override void HandleButtonUp(InputState state, List<Drawable> targets)
{
if (targets == null)
return;
protected override void HandleButtonUp(InputState state, List<Drawable> targets) =>
PropagateButtonEvent(targets, new KeyUpEvent(state, Button));
}
}
}

View File

@@ -17,12 +17,7 @@ namespace osu.Framework.Input
protected override Drawable HandleButtonDown(InputState state, List<Drawable> targets) => PropagateButtonEvent(targets, new MidiDownEvent(state, Button, state.Midi.Velocities[Button]));
protected override void HandleButtonUp(InputState state, List<Drawable> targets)
{
if (targets == null)
return;
protected override void HandleButtonUp(InputState state, List<Drawable> targets) =>
PropagateButtonEvent(targets, new MidiUpEvent(state, Button));
}
}
}

View File

@@ -30,7 +30,7 @@ namespace osu.Framework.Input
}
}
private void handleTextEditing(string text, int selectionStart, int selectionLength)
private void handleTextEditing(string? text, int selectionStart, int selectionLength)
{
if (text == null) return;

View File

@@ -41,7 +41,7 @@ namespace osu.Framework.Input.StateChanges
/// </remarks>
/// <param name="current">The newer <see cref="ButtonStates{TButton}"/>.</param>
/// <param name="previous">The older <see cref="ButtonStates{TButton}"/>.</param>
protected ButtonInput(ButtonStates<TButton> current, ButtonStates<TButton> previous)
protected ButtonInput(ButtonStates<TButton>? current, ButtonStates<TButton>? previous)
{
var difference = (current ?? new ButtonStates<TButton>()).EnumerateDifference(previous ?? new ButtonStates<TButton>());

View File

@@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using JetBrains.Annotations;
using osu.Framework.Input.States;
namespace osu.Framework.Input.StateChanges.Events
@@ -16,14 +15,12 @@ namespace osu.Framework.Input.StateChanges.Events
/// <summary>
/// The <see cref="InputState"/> changed by this event.
/// </summary>
[NotNull]
public readonly InputState State;
/// <summary>
/// The <see cref="IInput"/> that caused this input state change.
/// </summary>
[CanBeNull]
public readonly IInput Input;
public readonly IInput? Input;
protected InputStateChangeEvent(InputState state, IInput input)
{

View File

@@ -19,7 +19,7 @@ namespace osu.Framework.Input.StateChanges
{
}
public KeyboardKeyInput(ButtonStates<Key> current, ButtonStates<Key> previous)
public KeyboardKeyInput(ButtonStates<Key>? current, ButtonStates<Key>? previous)
: base(current, previous)
{
}

View File

@@ -17,12 +17,6 @@ namespace osu.Framework.Input
protected override Drawable HandleButtonDown(InputState state, List<Drawable> targets) => PropagateButtonEvent(targets, new TabletAuxiliaryButtonPressEvent(state, Button));
protected override void HandleButtonUp(InputState state, List<Drawable> targets)
{
if (targets == null)
return;
PropagateButtonEvent(targets, new TabletAuxiliaryButtonReleaseEvent(state, Button));
}
protected override void HandleButtonUp(InputState state, List<Drawable> targets) => PropagateButtonEvent(targets, new TabletAuxiliaryButtonReleaseEvent(state, Button));
}
}

View File

@@ -17,12 +17,6 @@ namespace osu.Framework.Input
protected override Drawable HandleButtonDown(InputState state, List<Drawable> targets) => PropagateButtonEvent(targets, new TabletPenButtonPressEvent(state, Button));
protected override void HandleButtonUp(InputState state, List<Drawable> targets)
{
if (targets == null)
return;
PropagateButtonEvent(targets, new TabletPenButtonReleaseEvent(state, Button));
}
protected override void HandleButtonUp(InputState state, List<Drawable> targets) => PropagateButtonEvent(targets, new TabletPenButtonReleaseEvent(state, Button));
}
}

View File

@@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@@ -31,7 +30,7 @@ namespace osu.Framework.Testing
}
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] TestBrowser browser)
private void load(TestBrowser? browser)
{
if (browser != null)
{

View File

@@ -28,7 +28,7 @@ namespace osu.Framework.Testing.Drawables.Steps
{
State = !State;
Light.FadeColour(State ? on_colour : off_colour);
reloadCallback?.Invoke(State);
reloadCallback.Invoke(State);
if (!State)
Success();

View File

@@ -13,7 +13,7 @@ namespace osu.Framework.Testing.Drawables
{
internal partial class TestGroupButton : VisibilityContainer, IFilterable
{
public IEnumerable<LocalisableString> FilterTerms => headerButton?.FilterTerms ?? Enumerable.Empty<LocalisableString>();
public IEnumerable<LocalisableString> FilterTerms => headerButton.FilterTerms;
public bool MatchingFilter
{

View File

@@ -12,7 +12,7 @@ namespace osu.Framework.Testing
/// <summary>
/// Find all children recursively of a specific type. As this is expensive and dangerous, it should only be used for testing purposes.
/// </summary>
public static IEnumerable<T> ChildrenOfType<T>(this Drawable drawable)
public static IEnumerable<T> ChildrenOfType<T>(this Drawable? drawable)
{
if (drawable is T match)
yield return match;

View File

@@ -33,6 +33,6 @@ namespace osu.Framework.Text
/// </summary>
public static bool IsWhiteSpace<T>(this T glyph)
where T : ITexturedCharacterGlyph
=> glyph.Texture == null || char.IsWhiteSpace(glyph.Character);
=> char.IsWhiteSpace(glyph.Character);
}
}

View File

@@ -13,7 +13,7 @@ namespace osu.Framework.Text
/// <param name="fontName">The name of the font.</param>
/// <param name="character">The character to retrieve.</param>
/// <returns>The character glyph.</returns>
ITexturedCharacterGlyph Get(string fontName, char character);
ITexturedCharacterGlyph? Get(string fontName, char character);
/// <summary>
/// Retrieves a glyph from the store asynchronously.
@@ -21,6 +21,6 @@ namespace osu.Framework.Text
/// <param name="fontName">The name of the font.</param>
/// <param name="character">The character to retrieve.</param>
/// <returns>The character glyph.</returns>
Task<ITexturedCharacterGlyph> GetAsync(string fontName, char character);
Task<ITexturedCharacterGlyph?> GetAsync(string fontName, char character);
}
}