Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable nullable reference types in Oakton project #102

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Oakton/ActivatorCommandCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

public class ActivatorCommandCreator : ICommandCreator
{
public IOaktonCommand CreateCommand(Type commandType)
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Argument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

public class Argument : TokenHandlerBase
{
private readonly MemberInfo _member;
Expand All @@ -19,7 +21,7 @@
{
_member = member;
_memberType = member.GetMemberType();
_converter = conversions.FindConverter(_memberType);

Check warning on line 24 in src/Oakton/Argument.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'type' in 'Func<string, object?>? Conversions.FindConverter(Type type)'.
}

public override bool Handle(object input, Queue<string> tokens)
Expand Down Expand Up @@ -55,7 +57,7 @@
public override string ToUsageDescription()
{
var memberType = _member.GetMemberType();
if (memberType.GetTypeInfo().IsEnum)

Check warning on line 60 in src/Oakton/Argument.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'type' in 'TypeInfo IntrospectionExtensions.GetTypeInfo(Type type)'.
{
return Enum.GetNames(memberType).Join("|");
}
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/CommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

/// <summary>
/// The main entry class for Oakton command line applications
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/CommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

public class CommandFactory : ICommandFactory
{
private static readonly string[] _helpCommands = { "help", "?" };
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/CommandFailureException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

public class CommandFailureException : Exception
{
public CommandFailureException(string message) : base(message)
Expand Down
2 changes: 0 additions & 2 deletions src/Oakton/CommandLineHostingExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#nullable enable

using JasperFx.Core;
using Microsoft.Extensions.Hosting;
using Oakton.Commands;
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/CommandRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

public class CommandRun
{
public IOaktonCommand Command { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Commands/CheckEnvironmentCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Oakton.Commands;

#nullable disable annotations // FIXME

public class CheckEnvironmentInput : NetCoreInput
{
[Description("Use to optionally write the results of the environment checks to a file")]
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Oakton.Commands;

#nullable disable annotations // FIXME

public class RunInput : NetCoreInput
{
[Description("Run the environment checks before starting the host")]
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/DependencyInjectionCommandCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

internal class DependencyInjectionCommandCreator : ICommandCreator
{
private readonly IServiceProvider _serviceProvider;
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/DescriptionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

/// <summary>
/// Adds a textual description to arguments or flags on input classes, or on a command class
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/ConfigurationPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

internal class ConfigurationPreview : IDescribedSystemPart, IWriteToConsole
{
private const string PreviewErrorMessage = "Unable to show a preview of the configuration.";
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/DescribeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

[Description("Writes out a description of your running application to either the console or a file")]
public class DescribeCommand : OaktonAsyncCommand<DescribeInput>
{
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/DescribeInput.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

public class DescribeInput : NetCoreInput
{
[Description("Optionally write the description to the given file location")]
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/DescriptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

public static class DescriptionExtensions
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/IDescribedSystemPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

#region sample_IDescribedSystemPart

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/IDescribedSystemPartFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

#region sample_IDescribedSystemPartFactory

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/IDescribesProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

/// <summary>
/// Interface to expose key/value pairs to diagnostic output
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/IRequiresServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

internal interface IRequiresServices
{
void Resolve(IServiceProvider services);
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/ITreeDescriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

/// <summary>
/// Interface to expose additional diagnostic information to a Spectre tree node
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/IWriteToConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

/// <summary>
/// Optional interface for exposing specialized console output
/// in the "describe" command
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Descriptions/LambdaDescribedSystemPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace Oakton.Descriptions;

#nullable disable annotations // FIXME

internal class LambdaDescribedSystemPart<T> : IDescribedSystemPart, IRequiresServices
{
private readonly Func<T, TextWriter, Task> _write;
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Environment/EnvironmentCheckException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace Oakton.Environment;

#nullable disable annotations // FIXME

public class EnvironmentCheckException : AggregateException
{
public EnvironmentCheckException(EnvironmentCheckResults results) : base(results.ToString(),
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Environment/EnvironmentCheckExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace Oakton.Environment;

#nullable disable annotations // FIXME

public static class EnvironmentCheckExtensions
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Environment/EnvironmentCheckResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Oakton.Environment;

#nullable disable annotations // FIXME

public class EnvironmentCheckResults
{
private readonly IList<EnvironmentFailure> _failures = new List<EnvironmentFailure>();
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Environment/EnvironmentChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace Oakton.Environment;

#nullable disable annotations // FIXME

/// <summary>
/// Executes the environment checks registered in an IoC container
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Environment/FileExistsCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace Oakton.Environment;

#nullable disable annotations // FIXME

public class FileExistsCheck : IEnvironmentCheck
{
private readonly string _file;
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Environment/IEnvironmentCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Oakton.Environment;

#nullable disable annotations // FIXME

#region sample_IEnvironmentCheck

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Environment/IEnvironmentCheckFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Oakton.Environment;

#nullable disable annotations // FIXME

public interface IEnvironmentCheckFactory
{
IEnvironmentCheck[] Build();
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Environment/LambdaCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Oakton.Environment;

#nullable disable annotations // FIXME

public class LambdaCheck : IEnvironmentCheck
{
private readonly Func<IServiceProvider, CancellationToken, Task> _action;
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/FlagAliasAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

/// <summary>
/// Use to override the long and/or short flag keys of a property or field
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Help/CommandUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Oakton.Help;

#nullable disable annotations // FIXME

public class CommandUsage
{
public string Description { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Help/HelpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Oakton.Help;

#nullable disable annotations // FIXME

[Description("List all the available commands", Name = "help")]
public class HelpCommand : OaktonCommand<HelpInput>
{
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Help/HelpInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace Oakton.Help;

#nullable disable annotations // FIXME

public class HelpInput
{
[IgnoreOnCommandLine] public IEnumerable<Type> CommandTypes { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Help/UsageGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Oakton.Help;

#nullable disable annotations // FIXME

public class UsageGraph
{
private readonly List<ITokenHandler> _handlers;
Expand All @@ -19,7 +21,7 @@

public UsageGraph(Type commandType)
{
_inputType = commandType.FindInterfaceThatCloses(typeof(IOaktonCommand<>)).GetTypeInfo()

Check warning on line 24 in src/Oakton/Help/UsageGraph.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'type' in 'TypeInfo IntrospectionExtensions.GetTypeInfo(Type type)'.
.GetGenericArguments().First();

CommandName = CommandFactory.CommandNameFor(commandType);
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/HostWrapperCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

internal class HostWrapperCommand : IOaktonCommand
{
private readonly IOaktonCommand _inner;
Expand Down
4 changes: 1 addition & 3 deletions src/Oakton/HostedCommandExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#nullable enable

using JasperFx.Core;
using JasperFx.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/ICommandCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

/// <summary>
/// Service locator for command types. The default just uses Activator.CreateInstance().
/// Can be used to plug in IoC construction in Oakton applications
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/ICommandFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

/// <summary>
/// Interface that Oakton uses to build command runs during execution. Can be used for custom
/// command activation
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/IHostBuilderInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

/// <summary>
/// Interface used to get access to the HostBuilder from command inputs.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/IOaktonCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

public interface IOaktonCommand
{
Type InputType { get; }
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/IServiceRegistrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton;

#nullable disable annotations // FIXME

/// <summary>
/// Implementations of this interface can be used to define
/// service registrations to be loaded by Oakton command extensions
Expand Down
2 changes: 2 additions & 0 deletions src/Oakton/Internal/ArgsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oakton.Internal;

#nullable disable annotations // FIXME

public static class ArgsExtensions
{
public static string[] FilterLauncherArgs(this string[] args)
Expand Down
3 changes: 2 additions & 1 deletion src/Oakton/Internal/Conversion/Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ namespace Oakton.Internal.Conversion;

public class Conversions
{
#nullable disable annotations // FIXME
private readonly LightweightCache<Type, Func<string, object>> _convertors;
private readonly IList<IConversionProvider> _providers = new List<IConversionProvider>();

#nullable restore

public Conversions()
{
Expand Down
Loading
Loading