Skip to content

Commit

Permalink
Fixes nullable warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaMarkic committed Feb 7, 2024
1 parent 6388d76 commit db2e505
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 37 deletions.
4 changes: 2 additions & 2 deletions src/Cake.Mage/BaseNewAndUpdateApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public abstract class BaseNewAndUpdateApplicationSettings : BaseNewAndUpdateMage
/// an application manifest.
/// </summary>
/// <value>From directory.</value>
public DirectoryPath FromDirectory { get; set; }
public DirectoryPath? FromDirectory { get; set; }

/// <summary>
/// Gets or sets if the deployment manifest will include the deployment
/// provider URL.
/// </summary>
/// <value>The icon file.</value>
public FilePath IconFile { get; set; }
public FilePath? IconFile { get; set; }

/// <summary>
/// Gets or sets the trust level to be included in the application manifest
Expand Down
10 changes: 5 additions & 5 deletions src/Cake.Mage/BaseNewAndUpdateDeploymentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ public abstract class BaseNewAndUpdateDeploymentSettings : BaseNewAndUpdateMageS
/// </summary>
/// <remarks>If specified <see cref="AppCodeBaseFilePath"/> must not be specified.</remarks>
/// <value>The application code base.</value>
public Uri AppCodeBaseUri { get; set; }
public Uri? AppCodeBaseUri { get; set; }

/// <summary>
/// Gets or sets the file path code base of the app manifest to be placed in the
/// deployment manifest being generated or updated.
/// </summary>
/// <remarks>If specified <see cref="AppCodeBaseUri"/> must not be specified.</remarks>
/// <value>The application code base.</value>
public FilePath AppCodeBaseFilePath { get; set; }
public FilePath? AppCodeBaseFilePath { get; set; }

/// <summary>
/// Gets or sets the local path to an application manifest that is being
/// referenced from the deployment manifest being generated or updated.
/// </summary>
/// <value>The application manifest.</value>
public FilePath AppManifest { get; set; }
public FilePath? AppManifest { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the deployment manifest will include the deployment
Expand All @@ -51,13 +51,13 @@ public abstract class BaseNewAndUpdateDeploymentSettings : BaseNewAndUpdateMageS
/// Must be of the form "0.0.0.0". Specifying "none" removes this from the manifest.
/// </summary>
/// <value>The minimum version.</value>
public string MinVersion { get; set; }
public string? MinVersion { get; set; }

/// <summary>
/// Gets or sets the provider URL to be use in the deployment manifest being
/// generated or updated.
/// </summary>
/// <value>The provider URL.</value>
public Uri ProviderUrl { get; set; }
public Uri? ProviderUrl { get; set; }
}
}
18 changes: 9 additions & 9 deletions src/Cake.Mage/BaseNewAndUpdateMageSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ public class BaseNewAndUpdateMageSettings : ToolSettings
/// manifest or license file.This option requires the -Password option.
/// </summary>
/// <value>The cert file.</value>
public FilePath CertFile { get; set; }
public FilePath? CertFile { get; set; }

/// <summary>
/// Gets or sets the hash of an X509 certificate in your local cert store.
/// </summary>
/// <value>The cert hash.</value>
public string CertHash { get; set; }
public string? CertHash { get; set; }

/// <summary>
/// Gets or sets the name of the application whose manifest is being
/// generated or updated.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
public string? Name { get; set; }

/// <summary>
/// Gets or sets the password to use with an X509 certificate when signing
/// a manifest or license file.
/// </summary>
/// <value>The password.</value>
public string Password { get; set; }
public string? Password { get; set; }

/// <summary>
/// Gets or sets the processor architecture of the application whose manifest
Expand All @@ -54,33 +54,33 @@ public class BaseNewAndUpdateMageSettings : ToolSettings
/// be enclosed in quotes.
/// </summary>
/// <value>The publisher.</value>
public string Publisher { get; set; }
public string? Publisher { get; set; }

/// <summary>
/// Gets or sets the support URL for the application.
/// </summary>
/// <value>The support URL.</value>
public Uri SupportUrl { get; set; }
public Uri? SupportUrl { get; set; }

/// <summary>
/// Gets or sets the URI to use for time stamping during signing.
/// </summary>
/// <value>The time stamp URI.</value>
public Uri TimeStampUri { get; set; }
public Uri? TimeStampUri { get; set; }

/// <summary>
/// Gets or sets the name of the file to save the output of a sign, new, or
/// update command.
/// </summary>
/// <value>To file.</value>
public FilePath ToFile { get; set; }
public FilePath? ToFile { get; set; }

/// <summary>
/// Gets or sets the version of the application whose manifest is being
/// generated or updated.Must be of the form "0.0.0.0".
/// </summary>
/// <value>The version.</value>
public string Version { get; set; }
public string? Version { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the application is a Windows Presentation Foundation Browser Application or not.
Expand Down
6 changes: 3 additions & 3 deletions src/Cake.Mage/DotNetToolResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal sealed class DotNetToolResolver
private readonly ICakeEnvironment _environment;
private readonly IRegistry _registry;
private readonly ICakeLog _log;
private FilePath _toolPath;
private FilePath? _toolPath;

public DotNetToolResolver(IFileSystem fileSystem, ICakeEnvironment environment, IRegistry registry, ICakeLog log)
{
Expand Down Expand Up @@ -49,7 +49,7 @@ public FilePath GetPath(string toolExecutable)
return _toolPath;
}

private FilePath GetFromDisc(string toolExecutable)
private FilePath? GetFromDisc(string toolExecutable)
{
// Get the path to program files.
var programFilesX86 = _environment.GetSpecialPath(SpecialPath.ProgramFilesX86);
Expand Down Expand Up @@ -100,7 +100,7 @@ private FilePath GetFromDisc(string toolExecutable)
return null;
}

private FilePath GetFromRegistry(string toolExecutable)
private FilePath? GetFromRegistry(string toolExecutable)
{
using (var root = _registry.LocalMachine.OpenKey("Software\\Microsoft\\Microsoft SDKs\\Windows"))
{
Expand Down
10 changes: 5 additions & 5 deletions src/Cake.Mage/MageAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class MageAliases
/// <param name="context">The context.</param>
/// <param name="settings">The settings.</param>
[CakeMethodAlias]
public static void MageNewApplication(this ICakeContext context, NewApplicationSettings settings)
public static void MageNewApplication(this ICakeContext context, NewApplicationSettings? settings)
{
if (settings == null) throw new ArgumentNullException(nameof(settings));

Expand All @@ -43,7 +43,7 @@ public static void MageNewApplication(this ICakeContext context, NewApplicationS
/// </code>
/// </example>
[CakeMethodAlias]
public static void MageNewDeployment(this ICakeContext context, NewDeploymentSettings settings)
public static void MageNewDeployment(this ICakeContext context, NewDeploymentSettings? settings)
{
if (settings == null) throw new ArgumentNullException(nameof(settings));

Expand All @@ -63,7 +63,7 @@ public static void MageNewDeployment(this ICakeContext context, NewDeploymentSet
/// });
/// </code></example>
[CakeMethodAlias]
public static void MageUpdateApplication(this ICakeContext context, UpdateApplicationSettings settings)
public static void MageUpdateApplication(this ICakeContext context, UpdateApplicationSettings? settings)
{
if (settings == null) throw new ArgumentNullException(nameof(settings));

Expand All @@ -83,7 +83,7 @@ public static void MageUpdateApplication(this ICakeContext context, UpdateApplic
/// </example>
/// </code>
[CakeMethodAlias]
public static void MageUpdateDeployment(this ICakeContext context, UpdateDeploymentSettings settings)
public static void MageUpdateDeployment(this ICakeContext context, UpdateDeploymentSettings? settings)
{
if (settings == null) throw new ArgumentNullException(nameof(settings));

Expand All @@ -104,7 +104,7 @@ public static void MageUpdateDeployment(this ICakeContext context, UpdateDeploym
/// </code>
/// </example>
[CakeMethodAlias]
public static void MageSign(this ICakeContext context, SignSettings settings)
public static void MageSign(this ICakeContext context, SignSettings? settings)
{
if (settings == null) throw new ArgumentNullException(nameof(settings));

Expand Down
17 changes: 9 additions & 8 deletions src/Cake.Mage/ProcessArgumentBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,41 @@ namespace Cake.Mage
{
internal static class ProcessArgumentBuilderExtensions
{
public static ProcessArgumentBuilder AppendNonEmptySwitch(this ProcessArgumentBuilder builder, string @switch, string text)
public static ProcessArgumentBuilder AppendNonEmptySwitch(this ProcessArgumentBuilder builder, string @switch, string? text)
{
return string.IsNullOrWhiteSpace(text) == false ? builder.AppendSwitch(@switch, text) : builder;
}

public static ProcessArgumentBuilder AppendNonEmptyQuotedSwitch(this ProcessArgumentBuilder builder, string @switch, string text)
public static ProcessArgumentBuilder AppendNonEmptyQuotedSwitch(this ProcessArgumentBuilder builder, string @switch, string? text)
{
return string.IsNullOrWhiteSpace(text) == false ? builder.AppendSwitchQuoted(@switch, text) : builder;
}

public static ProcessArgumentBuilder AppendNonEmptySecretSwitch(this ProcessArgumentBuilder builder, string @switch, string text)
public static ProcessArgumentBuilder AppendNonEmptySecretSwitch(this ProcessArgumentBuilder builder, string @switch, string? text)
{
return string.IsNullOrWhiteSpace(text) == false ? builder.AppendSwitchQuotedSecret(@switch, text) : builder;
}

public static ProcessArgumentBuilder AppendNonNullFilePathSwitch(this ProcessArgumentBuilder builder, string @switch, FilePath filePath, ICakeEnvironment environment)
public static ProcessArgumentBuilder AppendNonNullFilePathSwitch(this ProcessArgumentBuilder builder, string @switch, FilePath? filePath, ICakeEnvironment environment)
{
return filePath == null ? builder : builder.AppendSwitchQuoted(@switch, filePath.MakeAbsolute(environment).FullPath);
}
public static ProcessArgumentBuilder AppendNonNullRelativeFilePathSwitch(this ProcessArgumentBuilder builder, string @switch, FilePath filePath, ICakeEnvironment environment)
public static ProcessArgumentBuilder AppendNonNullRelativeFilePathSwitch(this ProcessArgumentBuilder builder, string @switch, FilePath? filePath, ICakeEnvironment environment)
{
return filePath == null ? builder : builder.AppendSwitchQuoted(@switch, filePath.FullPath);
}
public static ProcessArgumentBuilder AppendNonNullDirectoryPathSwitch(this ProcessArgumentBuilder builder, string @switch, DirectoryPath directoryPath, ICakeEnvironment environment)
public static ProcessArgumentBuilder AppendNonNullDirectoryPathSwitch(this ProcessArgumentBuilder builder, string @switch, DirectoryPath? directoryPath, ICakeEnvironment environment)
{
return directoryPath == null ? builder : builder.AppendSwitchQuoted(@switch, directoryPath.MakeAbsolute(environment).FullPath);
}

public static ProcessArgumentBuilder AppendNonNullUriSwitch(this ProcessArgumentBuilder builder, string @switch, Uri uri)
public static ProcessArgumentBuilder AppendNonNullUriSwitch(this ProcessArgumentBuilder builder, string @switch, Uri? uri)
{
return uri == null ? builder : builder.AppendSwitchQuoted(@switch, uri.ToString());
}

public static ProcessArgumentBuilder AppendIfNotDefaultSwitch<T>(this ProcessArgumentBuilder builder, string @switch, T value, T defaultValue)
public static ProcessArgumentBuilder AppendIfNotDefaultSwitch<T>(this ProcessArgumentBuilder builder, string @switch, T? value, T defaultValue)
where T: struct
{
return value == null || value.Equals(defaultValue) ? builder : builder.AppendSwitch(@switch, value.ToString());
}
Expand Down
10 changes: 5 additions & 5 deletions src/Cake.Mage/SignSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public SignSettings()
/// Gets or sets the file to sign.
/// </summary>
/// <value>The file to sign.</value>
public FilePath FileToSign { get; set; }
public FilePath? FileToSign { get; set; }

/// <summary>
/// Gets or sets the location of a digital certificate for signing a manifest
/// </summary>
/// <value>The password.</value>
public FilePath CertFile { get; set; }
public FilePath? CertFile { get; set; }

/// <summary>
/// <para>
Expand All @@ -50,19 +50,19 @@ public SignSettings()
/// </para>
/// </summary>
/// <value>The cert hash.</value>
public string CertHash { get; set; }
public string? CertHash { get; set; }

/// <summary>
/// Gets or sets the password that is used for signing a manifest with a digital certificate. Must be
/// used in conjunction with the CertFile option.
/// </summary>
/// <value>The password.</value>
public string Password { get; set; }
public string? Password { get; set; }

/// <summary>
/// Gets or sets the output path of the file that has been created or modified.
/// </summary>
/// <value>To file.</value>
public FilePath ToFile { get; set; }
public FilePath? ToFile { get; set; }
}
}

0 comments on commit db2e505

Please sign in to comment.