Skip to content

Commit

Permalink
Added support for redirecting the standard input of started processes. (
Browse files Browse the repository at this point in the history
#111)

Also enabled nullable on most projects and fixed resulting errors from it.
  • Loading branch information
AraHaan authored Dec 7, 2022
1 parent 9f34c0d commit 79a88da
Show file tree
Hide file tree
Showing 25 changed files with 160 additions and 90 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
fix that is to disable package analysis for now.
-->
<NoPackageAnalysis Condition="'$(PublishReferenceAssemblies)' == 'true'">true</NoPackageAnalysis>
<Nullable>enable</Nullable>
<ElskomOrgName>Els_kom org.</ElskomOrgName>
<Company>$(ElskomOrgName)</Company>
<Authors>$(ElskomOrgName)</Authors>
Expand Down
38 changes: 35 additions & 3 deletions ref/Common/Common/ProcessStartOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,44 @@ public bool WaitForProcessExit
set => throw null!;
}

/// <summary>
/// Gets where the standard input of the process is streamed to.
/// </summary>
public StreamWriter? Stdin
=> throw null!;

/// <summary>
/// Gets or sets where the standard output of the process is stream to.
/// </summary>
public StringBuilder? Stdout
{
get => throw null!;
set => throw null!;
}

/// <summary>
/// Gets or sets where the standard error of the process is stream to.
/// </summary>
public StringBuilder? Stderr
{
get => throw null!;
set => throw null!;
}

/// <summary>
/// Adds start information to this process options instance.
/// </summary>
/// <param name="fileName">The file name to execute.</param>
/// <param name="arguments">The arguments to execute the file with.</param>
/// <param name="redirectStandardOutput">Redirect standard output on the executed file.</param>
/// <param name="redirectStandardError">Redirect standard error on the executed file.</param>
/// <param name="redirectStandardInput">Redirect standard input on the executed process.</param>
/// <param name="redirectStandardOutput">Redirect standard output on the executed process.</param>
/// <param name="redirectStandardError">Redirect standard error on the executed process.</param>
/// <param name="useShellExecute">To optionally use shell execute to execute the process.</param>
/// <param name="createNoWindow">To optionally create no Window on the executed process.</param>
/// <param name="windowStyle">The window style to use on the executed process.</param>
/// <param name="workingDirectory">The working directory of the executed process.</param>
/// <returns>This instance of <see cref="ProcessStartOptions" />.</returns>
public ProcessStartOptions WithStartInformation(string fileName, string arguments, bool redirectStandardOutput, bool redirectStandardError, bool useShellExecute, bool createNoWindow, ProcessWindowStyle windowStyle, string workingDirectory)
public ProcessStartOptions WithStartInformation(string fileName, string arguments, bool redirectStandardInput, bool redirectStandardOutput, bool redirectStandardError, bool useShellExecute, bool createNoWindow, ProcessWindowStyle windowStyle, string workingDirectory)
=> throw null!;

/// <summary>
Expand All @@ -72,4 +97,11 @@ public string Start()
/// <exception cref="FileNotFoundException">When the file to the process to execute does not exist on disk.</exception>
public string Start(ProcessStartInfo startInfo)
=> throw null!;

/// <summary>
/// The string representation of the current output and/or error results from the process.
/// </summary>
/// <returns>string representation of the current output and/or error results from the process.</returns>
public override string ToString()
=> throw null!;
}
4 changes: 2 additions & 2 deletions ref/GitInformation/GitInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void ApplyAssemblyAttributes(Assembly assembly)
/// The <see cref="GitInformation"/> class instance to the specified <see cref="Type"/>
/// or <see langword="null"/>.
/// </returns>
public static GitInformation GetAssemblyInstance(Type assemblyType)
public static GitInformation? GetAssemblyInstance(Type assemblyType)
=> throw null!;

/// <summary>
Expand All @@ -117,6 +117,6 @@ public static GitInformation GetAssemblyInstance(Type assemblyType)
/// The <see cref="GitInformation"/> class instance to the specified <see cref="Assembly"/>
/// or <see langword="null"/>.
/// </returns>
public static GitInformation GetAssemblyInstance(Assembly assembly)
public static GitInformation? GetAssemblyInstance(Assembly assembly)
=> throw null!;
}
2 changes: 1 addition & 1 deletion ref/MessageManager/MessageManager/MessageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class MessageManager
/// <summary>
/// Occurs when the ShowError(), ShowInfo(), or ShowWarning() methods is told to use Notifications.
/// </summary>
public static event EventHandler<NotificationEventArgs> Notification
public static event EventHandler<NotificationEventArgs>? Notification
{
add => throw null!;
remove => throw null!;
Expand Down
4 changes: 2 additions & 2 deletions ref/MiniDump/MiniDump/MiniDumpAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public MiniDumpAttribute()
/// <summary>
/// Occurs when a mini-dump is generated or fails.
/// </summary>
public static event EventHandler<MessageEventArgs> DumpMessage
public static event EventHandler<MessageEventArgs>? DumpMessage
{
add => throw null!;
remove => throw null!;
Expand All @@ -38,7 +38,7 @@ public static event EventHandler<MessageEventArgs> DumpMessage
/// <summary>
/// Gets the current instance of this attribute.
/// </summary>
public static MiniDumpAttribute CurrentInstance
public static MiniDumpAttribute? CurrentInstance
=> throw null!;

/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions ref/PluginFramework/PluginFramework/ExecutionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public static bool IsElsKomRunning()
=> throw null!;

/// <summary>
/// Gets if Elsword or the launcher is currently executing.
/// </summary>
/// <returns>Boolean.</returns>
/// Gets if Elsword or the launcher is currently running.
/// </summary>
/// <param name="launcher">Get if the launcher is currently running.</param>
/// <returns>If the specified program is currently running.</returns>
public static bool IsExecuting(bool launcher)
=> throw null!;

Expand Down
4 changes: 2 additions & 2 deletions ref/PluginUpdateCheck/PluginUpdateCheck/PluginUpdateCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public PluginUpdateCheck(IServiceProvider serviceprovider)
/// <summary>
/// Event that fires when a new message should show up.
/// </summary>
public static event EventHandler<MessageEventArgs> MessageEvent
public static event EventHandler<MessageEventArgs>? MessageEvent
{
add => throw null!;
remove => throw null!;
Expand All @@ -29,7 +29,7 @@ public static event EventHandler<MessageEventArgs> MessageEvent
/// <summary>
/// Gets the plugin urls used in all instances.
/// </summary>
public List<string> PluginUrls
public List<string>? PluginUrls
=> throw null!;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public Uri DownloadUrl
/// <summary>
/// Gets the files to the plugin to download.
/// </summary>
public List<string> DownloadFiles
public List<string?> DownloadFiles
=> throw null!;
}
10 changes: 5 additions & 5 deletions ref/SettingsFile/SettingsFile/JsonSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public string[] Sources
/// </summary>
/// <param name="json">The json data to Deserialize.</param>
/// <returns>The target type instance for the settings file.</returns>
public static JsonSettings Deserialize(string json)
public static JsonSettings? Deserialize(string json)
=> throw null!;

/// <summary>
Expand All @@ -104,7 +104,7 @@ public static JsonSettings Deserialize(string json)
/// <param name="json">The json data to Deserialize.</param>
/// <param name="options">The options to deserialize with.</param>
/// <returns>The target type instance for the settings file.</returns>
public static JsonSettings Deserialize(string json, JsonSerializerOptions options)
public static JsonSettings? Deserialize(string json, JsonSerializerOptions? options)
=> throw null!;

/// <summary>
Expand All @@ -121,22 +121,22 @@ public static string Serialize(JsonSettings value)
/// <param name="value">The object for which holds the data to the input type instance.</param>
/// <param name="options">The options to serialize with.</param>
/// <returns>The json string to the input type instance's data.</returns>
public static string Serialize(JsonSettings value, JsonSerializerOptions options)
public static string Serialize(JsonSettings value, JsonSerializerOptions? options)
=> throw null!;

/// <summary>
/// Returns a new instance of this type either with preset contents
/// from the settings file or with default settings to create a settings file.
/// </summary>
/// <returns>A new instance of this type.</returns>
public static JsonSettings OpenFile()
public static JsonSettings? OpenFile()
=> throw null!;

/// <summary>
/// Returns a new instance of this type so this one can be discarded.
/// </summary>
/// <returns>A new instance of this type.</returns>
public JsonSettings ReopenFile()
public JsonSettings? ReopenFile()
=> throw null!;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion ref/SettingsFile/SettingsFile/SettingsFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static SettingsFile()
/// This is designed so there is globally only
/// a single instance to save time, and memory.
/// </value>
public static JsonSettings SettingsJson
public static JsonSettings? SettingsJson
{
get => throw null!;
set => throw null!;
Expand Down
2 changes: 1 addition & 1 deletion ref/ZipAssembly/ZipAssembly/ZipAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public override string Location
/// Any other exception not documented here indirectly thrown by this
/// If any other exceptions other than the ones above is thrown from a call to this, it exposes a bug.
/// </exception>
public static ZipAssembly LoadFromZip(string zipFileName, string assemblyName, AssemblyLoadContext context)
public static ZipAssembly? LoadFromZip(string zipFileName, string assemblyName, AssemblyLoadContext context)
=> throw null!;
}
22 changes: 11 additions & 11 deletions src/BlowFish/BlowFish/BlowFish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ public sealed partial class BlowFish

// SBLOCKS
[NullOnDispose]
private uint[] bfS0;
private uint[] bfS0 = null!;
[NullOnDispose]
private uint[] bfS1;
private uint[] bfS1 = null!;
[NullOnDispose]
private uint[] bfS2;
private uint[] bfS2 = null!;
[NullOnDispose]
private uint[] bfS3;
private uint[] bfS3 = null!;
[NullOnDispose]
private uint[] bfP;
private uint[] bfP = null!;

// HALF-BLOCKS
private uint xlPar;
private uint xrPar;
[NullOnDispose]
private byte[] initVector;
private byte[] initVector = null!;
private bool iVSet;

/// <summary>
Expand Down Expand Up @@ -64,7 +64,7 @@ public IEnumerable<byte> IV
get => this.initVector;
set
{
ThrowHelpers.ThrowInvalidOperation(value.ToArray().Length != 8, Resources.BlowFish_Invalid_IV_Size);
ThrowHelpers.ThrowInvalidOperation(value.ToArray().Length != 8, Resources.BlowFish_Invalid_IV_Size!);
this.initVector = value.ToArray();
this.iVSet = true;
}
Expand Down Expand Up @@ -393,7 +393,7 @@ public string DecryptECB(string ct)
/// <param name="cipherText">Ciphertext byte array.</param>
/// <param name="mode">Cipher mode.</param>
/// <returns>Plaintext or <see langword="null"/> if mode is not <see cref="CipherMode.ECB"/>.</returns>
public byte[] Decrypt(byte[] cipherText, CipherMode mode)
public byte[]? Decrypt(byte[] cipherText, CipherMode mode)
=> mode switch
{
CipherMode.ECB => this.Decrypt_ECB(cipherText),
Expand Down Expand Up @@ -485,7 +485,7 @@ private void SetupKey(Span<byte> cipherKey)
this.bfS1 = SetupS1.ToArray();
this.bfS2 = SetupS2.ToArray();
this.bfS3 = SetupS3.ToArray();
ThrowHelpers.ThrowInvalidOperation(cipherKey.Length > 56, Resources.BlowFish_Key_Too_Long);
ThrowHelpers.ThrowInvalidOperation(cipherKey.Length > 56, Resources.BlowFish_Key_Too_Long!);
var j = 0;
for (var i = 0; i < 18; i++)
{
Expand Down Expand Up @@ -559,15 +559,15 @@ private byte[] Crypt_ECB(byte[] text, bool decrypt)

private byte[] Crypt_CBC(byte[] text, bool decrypt)
{
ThrowHelpers.ThrowInvalidOperation(!this.iVSet, Resources.BlowFish_IV_Not_Set);
ThrowHelpers.ThrowInvalidOperation(!this.iVSet, Resources.BlowFish_IV_Not_Set!);
var paddedLen = text.Length % 8 == 0 ? text.Length : text.Length + 8 - (text.Length % 8);
if (paddedLen != text.Length)
{
Array.Resize(ref text, paddedLen);
}

var plainText = text.AsSpan();
byte[] preblock = null;
byte[]? preblock = null;
var iv = this.initVector.AsSpan().Slice(0, 8);
for (var i = 0; i < plainText.Length; i += 8)
{
Expand Down
Loading

0 comments on commit 79a88da

Please sign in to comment.