diff --git a/src/EFCore.Design/Design/IOperationResultHandler.cs b/src/EFCore.Design/Design/IOperationResultHandler.cs
index 5e14819e4d5..597aa26a16f 100644
--- a/src/EFCore.Design/Design/IOperationResultHandler.cs
+++ b/src/EFCore.Design/Design/IOperationResultHandler.cs
@@ -3,6 +3,8 @@
using JetBrains.Annotations;
+#nullable enable
+
namespace Microsoft.EntityFrameworkCore.Design
{
///
@@ -20,7 +22,7 @@ public interface IOperationResultHandler
/// Invoked when a result is available.
///
/// The result.
- void OnResult([CanBeNull] object value);
+ void OnResult([CanBeNull] object? value);
///
/// Invoked when an error occurs.
diff --git a/src/EFCore.Design/Design/OperationReportHandler.cs b/src/EFCore.Design/Design/OperationReportHandler.cs
index 56ed7cc42ab..9650023693b 100644
--- a/src/EFCore.Design/Design/OperationReportHandler.cs
+++ b/src/EFCore.Design/Design/OperationReportHandler.cs
@@ -4,6 +4,8 @@
using System;
using JetBrains.Annotations;
+#nullable enable
+
namespace Microsoft.EntityFrameworkCore.Design
{
///
@@ -11,10 +13,10 @@ namespace Microsoft.EntityFrameworkCore.Design
///
public class OperationReportHandler : MarshalByRefObject, IOperationReportHandler
{
- private readonly Action _errorHandler;
- private readonly Action _warningHandler;
- private readonly Action _informationHandler;
- private readonly Action _verboseHandler;
+ private readonly Action? _errorHandler;
+ private readonly Action? _warningHandler;
+ private readonly Action? _informationHandler;
+ private readonly Action? _verboseHandler;
///
/// Gets the contract version of this handler.
@@ -31,10 +33,10 @@ public virtual int Version
/// A callback for .
/// A callback for .
public OperationReportHandler(
- [CanBeNull] Action errorHandler = null,
- [CanBeNull] Action warningHandler = null,
- [CanBeNull] Action informationHandler = null,
- [CanBeNull] Action verboseHandler = null)
+ [CanBeNull] Action? errorHandler = null,
+ [CanBeNull] Action? warningHandler = null,
+ [CanBeNull] Action? informationHandler = null,
+ [CanBeNull] Action? verboseHandler = null)
{
_errorHandler = errorHandler;
_warningHandler = warningHandler;
diff --git a/src/EFCore.Design/Design/OperationResultHandler.cs b/src/EFCore.Design/Design/OperationResultHandler.cs
index 66d06df5f79..416d10aaa06 100644
--- a/src/EFCore.Design/Design/OperationResultHandler.cs
+++ b/src/EFCore.Design/Design/OperationResultHandler.cs
@@ -3,6 +3,8 @@
using System;
+#nullable enable
+
namespace Microsoft.EntityFrameworkCore.Design
{
///
@@ -11,10 +13,10 @@ namespace Microsoft.EntityFrameworkCore.Design
public class OperationResultHandler : MarshalByRefObject, IOperationResultHandler
{
private bool _hasResult;
- private object _result;
- private string _errorType;
- private string _errorMessage;
- private string _errorStackTrace;
+ private object? _result;
+ private string? _errorType;
+ private string? _errorMessage;
+ private string? _errorStackTrace;
///
/// Gets the contract version of this handler.
@@ -34,21 +36,21 @@ public virtual bool HasResult
/// Gets the result.
///
/// The result.
- public virtual object Result
+ public virtual object? Result
=> _result;
///
/// Gets the type of the exception if any.
///
/// The exception type.
- public virtual string ErrorType
+ public virtual string? ErrorType
=> _errorType;
///
/// Gets the error message if any.
///
/// The error message.
- public virtual string ErrorMessage
+ public virtual string? ErrorMessage
=> _errorMessage;
///
@@ -58,14 +60,14 @@ public virtual string ErrorMessage
///
/// When an is received, the stack trace should not be shown by default.
///
- public virtual string ErrorStackTrace
+ public virtual string? ErrorStackTrace
=> _errorStackTrace;
///
/// Invoked when a result is available.
///
/// The result.
- public virtual void OnResult(object value)
+ public virtual void OnResult(object? value)
{
_hasResult = true;
_result = value;
diff --git a/src/dotnet-ef/Exe.cs b/src/dotnet-ef/Exe.cs
index 1f48aa181e5..35e2b7d898f 100644
--- a/src/dotnet-ef/Exe.cs
+++ b/src/dotnet-ef/Exe.cs
@@ -12,7 +12,7 @@ internal static class Exe
public static int Run(
string executable,
IReadOnlyList args,
- string workingDirectory = null,
+ string? workingDirectory = null,
bool interceptOutput = false)
{
var arguments = ToArguments(args);
@@ -28,11 +28,11 @@ public static int Run(
startInfo.WorkingDirectory = workingDirectory;
}
- var process = Process.Start(startInfo);
+ var process = Process.Start(startInfo)!;
if (interceptOutput)
{
- string line;
+ string? line;
while ((line = process.StandardOutput.ReadLine()) != null)
{
Reporter.WriteVerbose(line);
diff --git a/src/dotnet-ef/Project.cs b/src/dotnet-ef/Project.cs
index ab3cede7437..823613db31f 100644
--- a/src/dotnet-ef/Project.cs
+++ b/src/dotnet-ef/Project.cs
@@ -12,11 +12,11 @@ namespace Microsoft.EntityFrameworkCore.Tools
internal class Project
{
private readonly string _file;
- private readonly string _framework;
- private readonly string _configuration;
- private readonly string _runtime;
+ private readonly string? _framework;
+ private readonly string? _configuration;
+ private readonly string? _runtime;
- public Project(string file, string framework, string configuration, string runtime)
+ public Project(string file, string? framework, string? configuration, string? runtime)
{
Debug.Assert(!string.IsNullOrEmpty(file), "file is null or empty.");
@@ -29,29 +29,29 @@ public Project(string file, string framework, string configuration, string runti
public string ProjectName { get; }
- public string AssemblyName { get; set; }
- public string Language { get; set; }
- public string OutputPath { get; set; }
- public string PlatformTarget { get; set; }
- public string ProjectAssetsFile { get; set; }
- public string ProjectDir { get; set; }
- public string RootNamespace { get; set; }
- public string RuntimeFrameworkVersion { get; set; }
- public string TargetFileName { get; set; }
- public string TargetFrameworkMoniker { get; set; }
+ public string? AssemblyName { get; set; }
+ public string? Language { get; set; }
+ public string? OutputPath { get; set; }
+ public string? PlatformTarget { get; set; }
+ public string? ProjectAssetsFile { get; set; }
+ public string? ProjectDir { get; set; }
+ public string? RootNamespace { get; set; }
+ public string? RuntimeFrameworkVersion { get; set; }
+ public string? TargetFileName { get; set; }
+ public string? TargetFrameworkMoniker { get; set; }
public static Project FromFile(
string file,
- string buildExtensionsDir,
- string framework = null,
- string configuration = null,
- string runtime = null)
+ string? buildExtensionsDir,
+ string? framework = null,
+ string? configuration = null,
+ string? runtime = null)
{
Debug.Assert(!string.IsNullOrEmpty(file), "file is null or empty.");
if (buildExtensionsDir == null)
{
- buildExtensionsDir = Path.Combine(Path.GetDirectoryName(file), "obj");
+ buildExtensionsDir = Path.Combine(Path.GetDirectoryName(file)!, "obj");
}
Directory.CreateDirectory(buildExtensionsDir);
@@ -60,7 +60,7 @@ public static Project FromFile(
buildExtensionsDir,
Path.GetFileName(file) + ".EntityFrameworkCore.targets");
using (var input = typeof(Resources).Assembly.GetManifestResourceStream(
- "Microsoft.EntityFrameworkCore.Tools.Resources.EntityFrameworkCore.targets"))
+ "Microsoft.EntityFrameworkCore.Tools.Resources.EntityFrameworkCore.targets")!)
using (var output = File.OpenWrite(efTargetsPath))
{
// NB: Copy always in case it changes
diff --git a/src/dotnet-ef/ProjectOptions.cs b/src/dotnet-ef/ProjectOptions.cs
index 1f7ef975872..0b13600fda1 100644
--- a/src/dotnet-ef/ProjectOptions.cs
+++ b/src/dotnet-ef/ProjectOptions.cs
@@ -8,13 +8,13 @@ namespace Microsoft.EntityFrameworkCore.Tools
{
internal class ProjectOptions
{
- public CommandOption Project { get; private set; }
- public CommandOption StartupProject { get; private set; }
- public CommandOption Framework { get; private set; }
- public CommandOption Configuration { get; private set; }
- public CommandOption Runtime { get; private set; }
- public CommandOption MSBuildProjectExtensionsPath { get; private set; }
- public CommandOption NoBuild { get; private set; }
+ public CommandOption? Project { get; private set; }
+ public CommandOption? StartupProject { get; private set; }
+ public CommandOption? Framework { get; private set; }
+ public CommandOption? Configuration { get; private set; }
+ public CommandOption? Runtime { get; private set; }
+ public CommandOption? MSBuildProjectExtensionsPath { get; private set; }
+ public CommandOption? NoBuild { get; private set; }
public void Configure(CommandLineApplication command)
{
diff --git a/src/dotnet-ef/RootCommand.cs b/src/dotnet-ef/RootCommand.cs
index 7db5d7f42f9..68537434222 100644
--- a/src/dotnet-ef/RootCommand.cs
+++ b/src/dotnet-ef/RootCommand.cs
@@ -17,17 +17,17 @@ namespace Microsoft.EntityFrameworkCore.Tools
{
internal class RootCommand : CommandBase
{
- private CommandLineApplication _command;
- private CommandOption _project;
- private CommandOption _startupProject;
- private CommandOption _framework;
- private CommandOption _configuration;
- private CommandOption _runtime;
- private CommandOption _msbuildprojectextensionspath;
- private CommandOption _noBuild;
- private CommandOption _help;
- private IList _args;
- private IList _applicationArgs;
+ private CommandLineApplication? _command;
+ private CommandOption? _project;
+ private CommandOption? _startupProject;
+ private CommandOption? _framework;
+ private CommandOption? _configuration;
+ private CommandOption? _runtime;
+ private CommandOption? _msbuildprojectextensionspath;
+ private CommandOption? _noBuild;
+ private CommandOption? _help;
+ private IList? _args;
+ private IList? _applicationArgs;
public override void Configure(CommandLineApplication command)
{
@@ -58,29 +58,29 @@ public override void Configure(CommandLineApplication command)
protected override int Execute(string[] _)
{
- var commands = _args.TakeWhile(a => a[0] != '-').ToList();
- if (_help.HasValue()
+ var commands = _args!.TakeWhile(a => a[0] != '-').ToList();
+ if (_help!.HasValue()
|| ShouldHelp(commands))
{
return ShowHelp(_help.HasValue(), commands);
}
var (projectFile, startupProjectFile) = ResolveProjects(
- _project.Value(),
- _startupProject.Value());
+ _project!.Value(),
+ _startupProject!.Value());
Reporter.WriteVerbose(Resources.UsingProject(projectFile));
Reporter.WriteVerbose(Resources.UsingStartupProject(startupProjectFile));
- var project = Project.FromFile(projectFile, _msbuildprojectextensionspath.Value());
+ var project = Project.FromFile(projectFile, _msbuildprojectextensionspath!.Value());
var startupProject = Project.FromFile(
startupProjectFile,
_msbuildprojectextensionspath.Value(),
- _framework.Value(),
- _configuration.Value(),
- _runtime.Value());
+ _framework!.Value(),
+ _configuration!.Value(),
+ _runtime!.Value());
- if (!_noBuild.HasValue())
+ if (!_noBuild!.HasValue())
{
Reporter.WriteInformation(Resources.BuildStarted);
startupProject.Build();
@@ -91,12 +91,12 @@ protected override int Execute(string[] _)
var args = new List();
var toolsPath = Path.Combine(
- Path.GetDirectoryName(typeof(Program).Assembly.Location),
+ Path.GetDirectoryName(typeof(Program).Assembly.Location)!,
"tools");
- var targetDir = Path.GetFullPath(Path.Combine(startupProject.ProjectDir, startupProject.OutputPath));
- var targetPath = Path.Combine(targetDir, project.TargetFileName);
- var startupTargetPath = Path.Combine(targetDir, startupProject.TargetFileName);
+ var targetDir = Path.GetFullPath(Path.Combine(startupProject.ProjectDir!, startupProject.OutputPath!));
+ var targetPath = Path.Combine(targetDir, project.TargetFileName!);
+ var startupTargetPath = Path.Combine(targetDir, startupProject.TargetFileName!);
var depsFile = Path.Combine(
targetDir,
startupProject.AssemblyName + ".deps.json");
@@ -105,7 +105,7 @@ protected override int Execute(string[] _)
startupProject.AssemblyName + ".runtimeconfig.json");
var projectAssetsFile = startupProject.ProjectAssetsFile;
- var targetFramework = new FrameworkName(startupProject.TargetFrameworkMoniker);
+ var targetFramework = new FrameworkName(startupProject.TargetFrameworkMoniker!);
if (targetFramework.Identifier == ".NETFramework")
{
executable = Path.Combine(
@@ -148,7 +148,7 @@ protected override int Execute(string[] _)
args.Add("--runtimeconfig");
args.Add(runtimeConfig);
}
- else if (startupProject.RuntimeFrameworkVersion.Length != 0)
+ else if (startupProject.RuntimeFrameworkVersion!.Length != 0)
{
args.Add("--fx-version");
args.Add(startupProject.RuntimeFrameworkVersion);
@@ -166,15 +166,15 @@ protected override int Execute(string[] _)
Resources.UnsupportedFramework(startupProject.ProjectName, targetFramework.Identifier));
}
- args.AddRange(_args);
+ args.AddRange(_args!);
args.Add("--assembly");
args.Add(targetPath);
args.Add("--startup-assembly");
args.Add(startupTargetPath);
args.Add("--project-dir");
- args.Add(project.ProjectDir);
+ args.Add(project.ProjectDir!);
args.Add("--language");
- args.Add(project.Language);
+ args.Add(project.Language!);
args.Add("--working-dir");
args.Add(Directory.GetCurrentDirectory());
@@ -193,24 +193,24 @@ protected override int Execute(string[] _)
args.Add("--prefix-output");
}
- if (project.RootNamespace.Length != 0)
+ if (project.RootNamespace!.Length != 0)
{
args.Add("--root-namespace");
args.Add(project.RootNamespace);
}
- if (_applicationArgs.Any())
+ if (_applicationArgs!.Any())
{
args.Add("--");
- args.AddRange(_applicationArgs);
+ args.AddRange(_applicationArgs!);
}
return Exe.Run(executable, args, startupProject.ProjectDir);
}
private static (string, string) ResolveProjects(
- string projectPath,
- string startupProjectPath)
+ string? projectPath,
+ string? startupProjectPath)
{
var projects = ResolveProjects(projectPath);
var startupProjects = ResolveProjects(startupProjectPath);
@@ -264,7 +264,7 @@ private static (string, string) ResolveProjects(
return (projects[0], startupProjects[0]);
}
- private static List ResolveProjects(string path)
+ private static List ResolveProjects(string? path)
{
if (path == null)
{
@@ -283,7 +283,7 @@ private static List ResolveProjects(string path)
}
private static string GetVersion()
- => typeof(RootCommand).Assembly.GetCustomAttribute()
+ => typeof(RootCommand).Assembly.GetCustomAttribute()!
.InformationalVersion;
private static bool ShouldHelp(IReadOnlyList commands)
@@ -295,7 +295,7 @@ private static bool ShouldHelp(IReadOnlyList commands)
private int ShowHelp(bool help, IEnumerable commands)
{
- var app = new CommandLineApplication { Name = _command.Name };
+ var app = new CommandLineApplication { Name = _command!.Name };
new EFCommand().Configure(app);
diff --git a/src/dotnet-ef/dotnet-ef.csproj b/src/dotnet-ef/dotnet-ef.csproj
index 789102c22a5..b64af669f97 100644
--- a/src/dotnet-ef/dotnet-ef.csproj
+++ b/src/dotnet-ef/dotnet-ef.csproj
@@ -27,6 +27,7 @@ dotnet ef database update
-->
false
Major
+ enable
diff --git a/src/ef/AnsiConsole.cs b/src/ef/AnsiConsole.cs
index 550fb4bf130..849c07c0db1 100644
--- a/src/ef/AnsiConsole.cs
+++ b/src/ef/AnsiConsole.cs
@@ -9,7 +9,7 @@ internal static class AnsiConsole
{
public static readonly AnsiTextWriter _out = new(Console.Out);
- public static void WriteLine(string text)
+ public static void WriteLine(string? text)
=> _out.WriteLine(text);
}
}
diff --git a/src/ef/AnsiTextWriter.cs b/src/ef/AnsiTextWriter.cs
index 737552a824e..3f1ab5362bd 100644
--- a/src/ef/AnsiTextWriter.cs
+++ b/src/ef/AnsiTextWriter.cs
@@ -4,6 +4,7 @@
using System;
using System.Diagnostics;
using System.IO;
+using System.Linq;
using System.Text.RegularExpressions;
namespace Microsoft.EntityFrameworkCore.Tools
@@ -14,23 +15,23 @@ internal class AnsiTextWriter
public AnsiTextWriter(TextWriter writer) => _writer = writer;
- public void WriteLine(string text)
+ public void WriteLine(string? text)
{
Interpret(text);
_writer.Write(Environment.NewLine);
}
- private void Interpret(string value)
+ private void Interpret(string? value)
{
var matches = Regex.Matches(value, "\x1b\\[([0-9]+)?m");
var start = 0;
- foreach (Match match in matches)
+ foreach (var match in matches.Cast())
{
var length = match.Index - start;
if (length != 0)
{
- _writer.Write(value.Substring(start, length));
+ _writer.Write(value!.Substring(start, length));
}
Apply(match.Groups[1].Value);
@@ -38,9 +39,9 @@ private void Interpret(string value)
start = match.Index + match.Length;
}
- if (start != value.Length)
+ if (start != value?.Length)
{
- _writer.Write(value.Substring(start));
+ _writer.Write(value?.Substring(start));
}
}
diff --git a/src/ef/AppDomainOperationExecutor.cs b/src/ef/AppDomainOperationExecutor.cs
index acf58cde203..69438de5ad9 100644
--- a/src/ef/AppDomainOperationExecutor.cs
+++ b/src/ef/AppDomainOperationExecutor.cs
@@ -20,11 +20,11 @@ internal class AppDomainOperationExecutor : OperationExecutorBase
public AppDomainOperationExecutor(
string assembly,
- string startupAssembly,
- string projectDir,
- string dataDirectory,
- string rootNamespace,
- string language,
+ string? startupAssembly,
+ string? projectDir,
+ string? dataDirectory,
+ string? rootNamespace,
+ string? language,
string[] remainingArguments)
: base(assembly, startupAssembly, projectDir, rootNamespace, language, remainingArguments)
{
diff --git a/src/ef/CommandLineUtils/CommandArgument.cs b/src/ef/CommandLineUtils/CommandArgument.cs
index fae1fb16620..b887ce73702 100644
--- a/src/ef/CommandLineUtils/CommandArgument.cs
+++ b/src/ef/CommandLineUtils/CommandArgument.cs
@@ -10,10 +10,10 @@ internal class CommandArgument
{
public CommandArgument() => Values = new List();
- public string Name { get; set; }
- public string Description { get; set; }
+ public string? Name { get; set; }
+ public string? Description { get; set; }
public List Values { get; }
public bool MultipleValues { get; set; }
- public string Value => Values.FirstOrDefault();
+ public string? Value => Values.FirstOrDefault();
}
}
diff --git a/src/ef/CommandLineUtils/CommandLineApplication.cs b/src/ef/CommandLineUtils/CommandLineApplication.cs
index 502b5c9766b..d820dd2d38c 100644
--- a/src/ef/CommandLineUtils/CommandLineApplication.cs
+++ b/src/ef/CommandLineUtils/CommandLineApplication.cs
@@ -38,26 +38,26 @@ public CommandLineApplication(bool throwOnUnexpectedArg = true)
Invoke = (args) => 0;
}
- public CommandLineApplication Parent { get; set; }
- public string Name { get; set; }
- public string FullName { get; set; }
- public string Syntax { get; set; }
- public string Description { get; set; }
+ public CommandLineApplication? Parent { get; set; }
+ public string? Name { get; set; }
+ public string? FullName { get; set; }
+ public string? Syntax { get; set; }
+ public string? Description { get; set; }
public List Options { get; }
- public CommandOption OptionHelp { get; private set; }
- public CommandOption OptionVersion { get; private set; }
+ public CommandOption? OptionHelp { get; private set; }
+ public CommandOption? OptionVersion { get; private set; }
public List Arguments { get; }
public List RemainingArguments { get; }
public List ApplicationArguments { get; }
public bool IsShowingInformation { get; protected set; } // Is showing help or version?
- public Func Invoke { get; set; }
- public Func LongVersionGetter { get; set; }
- public Func ShortVersionGetter { get; set; }
+ public Func Invoke { get; set; }
+ public Func? LongVersionGetter { get; set; }
+ public Func? ShortVersionGetter { get; set; }
public List Commands { get; }
public bool HandleResponseFiles { get; set; }
public bool AllowArgumentSeparator { get; set; }
public bool HandleRemainingArguments { get; set; }
- public string ArgumentSeparatorHelpText { get; set; }
+ public string? ArgumentSeparatorHelpText { get; set; }
public CommandLineApplication Command(string name, bool throwOnUnexpectedArg = true)
=> Command(name, _ => { }, throwOnUnexpectedArg);
@@ -72,10 +72,10 @@ public CommandLineApplication Command(
return command;
}
- public CommandOption Option(string template, string description, CommandOptionType optionType)
+ public CommandOption Option(string template, string? description, CommandOptionType optionType)
=> Option(template, description, optionType, _ => { });
- public CommandOption Option(string template, string description, CommandOptionType optionType, Action configuration)
+ public CommandOption Option(string template, string? description, CommandOptionType optionType, Action configuration)
{
var option = new CommandOption(template, optionType) { Description = description };
Options.Add(option);
@@ -164,7 +164,7 @@ private ParseOptionResult ParseOption(
CommandLineApplication command,
string[] args,
ref int index,
- out CommandOption option)
+ out CommandOption? option)
{
option = null;
var result = ParseOptionResult.Succeeded;
@@ -253,7 +253,7 @@ private ParseOptionResult ParseOption(
return result;
}
- private static CommandLineApplication ParseSubCommand(string arg, CommandLineApplication command)
+ private static CommandLineApplication? ParseSubCommand(string arg, CommandLineApplication command)
{
foreach (var subcommand in command.Commands)
{
@@ -279,7 +279,7 @@ public CommandOption HelpOption(string template)
public CommandOption VersionOption(
string template,
string shortFormVersion,
- string longFormVersion = null)
+ string? longFormVersion = null)
{
if (longFormVersion == null)
{
@@ -293,7 +293,7 @@ public CommandOption VersionOption(
public CommandOption VersionOption(
string template,
Func shortFormVersionGetter,
- Func longFormVersionGetter = null)
+ Func? longFormVersionGetter = null)
{
// Version option is special because we stop parsing once we see it
// So we store it separately for further use
@@ -314,7 +314,7 @@ public void ShowHint()
}
// Show full help
- public void ShowHelp(string commandName = null)
+ public void ShowHelp(string? commandName = null)
{
var headerBuilder = new StringBuilder("Usage:");
var usagePrefixLength = headerBuilder.Length;
@@ -333,7 +333,7 @@ public void ShowHelp(string commandName = null)
}
}
- CommandLineApplication target;
+ CommandLineApplication? target;
if (commandName == null
|| string.Equals(Name, commandName, StringComparison.OrdinalIgnoreCase))
@@ -389,7 +389,7 @@ public void ShowHelp(string commandName = null)
{
argumentsBuilder.AppendFormat(
outputFormat,
- arg.Name.PadRight(maxArgLen + 2),
+ arg.Name!.PadRight(maxArgLen + 2),
arg.Description);
argumentsBuilder.AppendLine();
}
@@ -473,10 +473,10 @@ public void ShowVersion()
}
Console.WriteLine(FullName);
- Console.WriteLine(LongVersionGetter());
+ Console.WriteLine(LongVersionGetter!());
}
- public string GetFullNameAndVersion()
+ public string? GetFullNameAndVersion()
=> ShortVersionGetter == null ? FullName : string.Format("{0} {1}", FullName, ShortVersionGetter());
public void ShowRootCommandFullNameAndVersion()
@@ -507,7 +507,7 @@ private static int MaxCommandLength(IEnumerable commands
var maxLen = 0;
foreach (var cmd in commands)
{
- maxLen = cmd.Name.Length > maxLen ? cmd.Name.Length : maxLen;
+ maxLen = cmd.Name!.Length > maxLen ? cmd.Name.Length : maxLen;
}
return maxLen;
@@ -518,7 +518,7 @@ private static int MaxArgumentLength(IEnumerable arguments)
var maxLen = 0;
foreach (var arg in arguments)
{
- maxLen = arg.Name.Length > maxLen ? arg.Name.Length : maxLen;
+ maxLen = arg.Name!.Length > maxLen ? arg.Name.Length : maxLen;
}
return maxLen;
@@ -568,7 +568,7 @@ private IEnumerable ExpandResponseFiles(IEnumerable args)
}
}
- private IEnumerable ParseResponseFile(string fileName)
+ private IEnumerable? ParseResponseFile(string fileName)
{
if (!HandleResponseFiles)
{
diff --git a/src/ef/CommandLineUtils/CommandLineApplicationExtensions.cs b/src/ef/CommandLineUtils/CommandLineApplicationExtensions.cs
index 7a1ab6040cb..dec20298c62 100644
--- a/src/ef/CommandLineUtils/CommandLineApplicationExtensions.cs
+++ b/src/ef/CommandLineUtils/CommandLineApplicationExtensions.cs
@@ -7,7 +7,7 @@ namespace Microsoft.DotNet.Cli.CommandLine
{
internal static class CommandLineApplicationExtensions
{
- public static CommandOption Option(this CommandLineApplication command, string template, string description)
+ public static CommandOption Option(this CommandLineApplication command, string template, string? description)
=> command.Option(
template,
description,
diff --git a/src/ef/CommandLineUtils/CommandOption.cs b/src/ef/CommandLineUtils/CommandOption.cs
index f85a9da1d14..11fa1a35bb6 100644
--- a/src/ef/CommandLineUtils/CommandOption.cs
+++ b/src/ef/CommandLineUtils/CommandOption.cs
@@ -13,7 +13,7 @@ public CommandOption(string template, CommandOptionType optionType)
{
Template = template;
OptionType = optionType;
- Values = new List();
+ Values = new List();
foreach (var part in Template.Split(new[] { ' ', '|' }, StringSplitOptions.RemoveEmptyEntries))
{
@@ -62,16 +62,16 @@ public CommandOption(string template, CommandOptionType optionType)
}
public string Template { get; set; }
- public string ShortName { get; set; }
- public string LongName { get; set; }
- public string SymbolName { get; set; }
- public string ValueName { get; set; }
- public string Description { get; set; }
- public List Values { get; }
+ public string? ShortName { get; set; }
+ public string? LongName { get; set; }
+ public string? SymbolName { get; set; }
+ public string? ValueName { get; set; }
+ public string? Description { get; set; }
+ public List Values { get; }
public bool? BoolValue { get; private set; }
public CommandOptionType OptionType { get; }
- public bool TryParse(string value)
+ public bool TryParse(string? value)
{
switch (OptionType)
{
@@ -126,7 +126,7 @@ public bool TryParse(string value)
public bool HasValue() => Values.Count > 0;
- public string Value() => HasValue() ? Values[0] : null;
+ public string? Value() => HasValue() ? Values[0] : null;
private static bool IsEnglishLetter(char c) => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
diff --git a/src/ef/Commands/ContextCommandBase.cs b/src/ef/Commands/ContextCommandBase.cs
index 8b4232815b2..e0205897122 100644
--- a/src/ef/Commands/ContextCommandBase.cs
+++ b/src/ef/Commands/ContextCommandBase.cs
@@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Tools.Commands
{
internal class ContextCommandBase : ProjectCommandBase
{
- protected CommandOption Context { get; private set; }
+ protected CommandOption? Context { get; private set; }
public override void Configure(CommandLineApplication command)
{
diff --git a/src/ef/Commands/DatabaseDropCommand.Configure.cs b/src/ef/Commands/DatabaseDropCommand.Configure.cs
index 65df319a1c3..57791972f02 100644
--- a/src/ef/Commands/DatabaseDropCommand.Configure.cs
+++ b/src/ef/Commands/DatabaseDropCommand.Configure.cs
@@ -8,8 +8,8 @@ namespace Microsoft.EntityFrameworkCore.Tools.Commands
{
internal partial class DatabaseDropCommand : ContextCommandBase
{
- private CommandOption _force;
- private CommandOption _dryRun;
+ private CommandOption? _force;
+ private CommandOption? _dryRun;
public override void Configure(CommandLineApplication command)
{
diff --git a/src/ef/Commands/DatabaseDropCommand.cs b/src/ef/Commands/DatabaseDropCommand.cs
index f5405598eb0..a4466c26e29 100644
--- a/src/ef/Commands/DatabaseDropCommand.cs
+++ b/src/ef/Commands/DatabaseDropCommand.cs
@@ -13,32 +13,32 @@ protected override int Execute(string[] args)
{
using var executor = CreateExecutor(args);
- void LogDropCommand(Func