diff --git a/sdks/dotnet/.editorconfig b/sdks/dotnet/.editorconfig new file mode 100644 index 0000000..b86e18c --- /dev/null +++ b/sdks/dotnet/.editorconfig @@ -0,0 +1,26 @@ +[*.cs] +# Rule: Remove unused using directives +# Setting severity to 'suggestion', 'warning', or 'error' will enable the analyzer. +# Code cleanup tools (like in Visual Studio or `dotnet format`) can then remove them. +# 'silent' would still report it for `dotnet format` but not show in IDE as a squiggle. +# 'none' would disable the check entirely. +dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = true +csharp_preferred_using_directive_placement = outside_namespace +indent_size = 2 + +# Suppressed above diagnostics for all .cs files +dotnet_diagnostic.CS8604.severity = none +dotnet_diagnostic.IDE0005.severity = none +dotnet_diagnostic.IDE0011.severity = none +dotnet_diagnostic.IDE1006.severity = none +dotnet_diagnostic.IDE2000.severity = none +dotnet_diagnostic.IDE2002.severity = none +dotnet_diagnostic.CS8600.severity = none +dotnet_diagnostic.CS8602.severity = none +dotnet_diagnostic.IDE0009.severity = none +dotnet_diagnostic.IDE0017.severity = none +dotnet_diagnostic.IDE0028.severity = none +dotnet_diagnostic.CS8603.severity = none +dotnet_diagnostic.CS8424.severity = none +dotnet_diagnostic.CS0108.severity = none \ No newline at end of file diff --git a/sdks/dotnet/BinaryInstaller.cs b/sdks/dotnet/BinaryInstaller.cs index 2ea5fb6..9b42179 100644 --- a/sdks/dotnet/BinaryInstaller.cs +++ b/sdks/dotnet/BinaryInstaller.cs @@ -14,17 +14,13 @@ * limitations under the License. */ -using System; -using System.IO; -using System.Net.Http; -using System.Security.Cryptography; -using System.Text.Json; -using System.Threading.Tasks; -using System.Runtime.InteropServices; -using System.Diagnostics; -using SharpCompress.Readers; using SharpCompress.Common; +using SharpCompress.Readers; +using System.Diagnostics; using System.Reflection; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text.Json; namespace TestServerSdk { @@ -154,7 +150,11 @@ private static async Task ComputeSha256Async(string filePath) { using var stream = File.OpenRead(filePath); using var sha = SHA256.Create(); +#if NET6_0_OR_GREATER var hash = await sha.ComputeHashAsync(stream); +#else + var hash = sha.ComputeHash(stream); +#endif return BitConverter.ToString(hash).Replace("-", string.Empty).ToLowerInvariant(); } @@ -163,7 +163,11 @@ private static void ExtractArchive(string archivePath, string archiveExt, string Console.WriteLine($"[TestServerSDK] Extracting {archivePath} to {destDir}..."); if (archiveExt == ".zip") { +#if NET6_0_OR_GREATER System.IO.Compression.ZipFile.ExtractToDirectory(archivePath, destDir, true); +#else + System.IO.Compression.ZipFile.ExtractToDirectory(archivePath, destDir); +#endif } else { diff --git a/sdks/dotnet/TestServerSdk.csproj b/sdks/dotnet/TestServerSdk.csproj index 1c6f6bc..5053904 100644 --- a/sdks/dotnet/TestServerSdk.csproj +++ b/sdks/dotnet/TestServerSdk.csproj @@ -1,6 +1,6 @@ - net6.0;net8.0 + net6.0;net8.0;netstandard2.0 latest enable enable @@ -33,4 +33,9 @@ + + + + +