Skip to content

Commit

Permalink
Enable nullable reference type
Browse files Browse the repository at this point in the history
  • Loading branch information
jsakamoto committed Dec 13, 2023
1 parent ca49aa4 commit 64db869
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Toolbelt.Blazor.Gamepad/Gamepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Gamepad

private ValueTask<object> LastRefreshTask = default;

private DotNetObjectReference<Gamepad> _ObjectRefOfThis;
private DotNetObjectReference<Gamepad>? _ObjectRefOfThis;

internal Gamepad(JSInvoker jsInvoker, string id, int index, bool connected)
{
Expand Down
4 changes: 2 additions & 2 deletions Toolbelt.Blazor.Gamepad/GamepadExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public static IServiceCollection AddGamepadList(this IServiceCollection services
/// </summary>
/// <param name="services">The Microsoft.Extensions.DependencyInjection.IServiceCollection to add the service to.</param>
/// <param name="configure"></param>
public static IServiceCollection AddGamepadList(this IServiceCollection services, Action<GamepadOptions> configure)
public static IServiceCollection AddGamepadList(this IServiceCollection services, Action<GamepadOptions>? configure)
{
var options = new GamepadOptions();
configure?.Invoke(options);
services.AddScoped(serviceProvider => new GamepadList(serviceProvider.GetService<IJSRuntime>(), options));
services.AddScoped(serviceProvider => new GamepadList(serviceProvider.GetRequiredService<IJSRuntime>(), options));
return services;
}
}
10 changes: 5 additions & 5 deletions Toolbelt.Blazor.Gamepad/GamepadList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public class GamepadList : IAsyncDisposable
{
private readonly IJSRuntime JSRuntime;

private JSInvoker JSInvoker;
private IJSObjectReference? JSModule;

private JSInvoker? JSInvoker;

private readonly GamepadOptions Options;

Expand Down Expand Up @@ -52,7 +54,7 @@ public async ValueTask<IReadOnlyList<Gamepad>> GetGamepadsAsync()
return this._Gamepads;
}

private async ValueTask<JSInvoker> GetJSInvokerAsync()
private async ValueTask<JSInvoker?> GetJSInvokerAsync()
{
if (this.JSInvoker != null) return this.JSInvoker;

Expand Down Expand Up @@ -85,12 +87,10 @@ private string GetVersionText()
var assembly = this.GetType().Assembly;
var version = assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
.InformationalVersion ?? assembly.GetName().Version.ToString();
.InformationalVersion ?? assembly.GetName().Version?.ToString() ?? "0.0.0";
return version;
}

private IJSObjectReference JSModule;

public async ValueTask DisposeAsync()
{
if (this.JSModule != null) await this.JSModule.DisposeAsync();
Expand Down
3 changes: 1 addition & 2 deletions Toolbelt.Blazor.Gamepad/JSInvoker.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#nullable enable
using Microsoft.JSInterop;
using Microsoft.JSInterop;

namespace Toolbelt.Blazor.Gamepad;

Expand Down
1 change: 1 addition & 0 deletions Toolbelt.Blazor.Gamepad/Toolbelt.Blazor.Gamepad.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<WarningsAsErrors>$(WarningsAsErrors);nullable</WarningsAsErrors>
Expand Down

0 comments on commit 64db869

Please sign in to comment.