Skip to content

Commit

Permalink
.NET resolve suggested warnings (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton authored Sep 21, 2023
1 parent 662a92d commit bbbfdc6
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 40 deletions.
2 changes: 1 addition & 1 deletion languages/csharp/Bitwarden.Sdk/BitwardenAuthException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public BitwardenAuthException(string message) : base(message)
{
}

public BitwardenAuthException(string message, System.Exception innerException)
public BitwardenAuthException(string message, Exception innerException)
: base(message, innerException)
{
}
Expand Down
11 changes: 5 additions & 6 deletions languages/csharp/Bitwarden.Sdk/BitwardenClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public BitwardenClient(BitwardenSettings? settings = null)
{
var clientSettings = new ClientSettings
{
ApiUrl = settings?.ApiUrl!, IdentityUrl = settings?.IdentityUrl!, UserAgent = "Bitwarden DOTNET-SDK"
ApiUrl = settings?.ApiUrl!,
IdentityUrl = settings?.IdentityUrl!,
UserAgent = "Bitwarden DOTNET-SDK"
};

_handle = BitwardenLibrary.Init(clientSettings.ToJson());
Expand All @@ -20,7 +22,7 @@ public BitwardenClient(BitwardenSettings? settings = null)

public void AccessTokenLogin(string accessToken)
{
var command = new Command() { AccessTokenLogin = new AccessTokenLoginRequest { AccessToken = accessToken } };
var command = new Command { AccessTokenLogin = new AccessTokenLoginRequest { AccessToken = accessToken } };
var response = _commandRunner.RunCommand<ResponseForApiKeyLoginResponse>(command);
if (response is not { Success: true })
{
Expand All @@ -32,8 +34,5 @@ public void AccessTokenLogin(string accessToken)

public SecretsClient Secrets { get; }

public void Dispose()
{
_handle.Dispose();
}
public void Dispose() => _handle.Dispose();
}
2 changes: 1 addition & 1 deletion languages/csharp/Bitwarden.Sdk/BitwardenException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public BitwardenException(string message) : base(message)
{
}

public BitwardenException(string message, System.Exception innerException)
public BitwardenException(string message, Exception innerException)
: base(message, innerException)
{
}
Expand Down
18 changes: 4 additions & 14 deletions languages/csharp/Bitwarden.Sdk/BitwardenLibrary.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;

namespace Bitwarden.Sdk;

Expand All @@ -14,18 +13,9 @@ internal static class BitwardenLibrary
[DllImport("bitwarden_c", CallingConvention = CallingConvention.Cdecl)]
private static extern string run_command(string json, BitwardenSafeHandle handle);

internal static BitwardenSafeHandle Init(string settings)
{
return init(settings);
}
internal static BitwardenSafeHandle Init(string settings) => init(settings);

internal static void FreeMemory(IntPtr handle)
{
free_mem(handle);
}
internal static void FreeMemory(IntPtr handle) => free_mem(handle);

internal static string RunCommand(string json, BitwardenSafeHandle handle)
{
return run_command(json, handle);
}
internal static string RunCommand(string json, BitwardenSafeHandle handle) => run_command(json, handle);
}
3 changes: 1 addition & 2 deletions languages/csharp/Bitwarden.Sdk/BitwardenSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public class BitwardenSettings
public string? ApiUrl { get; set; }

/// <summary>
/// The identity url of the targeted Bitwarden instance. Defaults to
/// `https://identity.bitwarden.com`
/// The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`
/// </summary>
public string? IdentityUrl { get; set; }
}
6 changes: 3 additions & 3 deletions languages/csharp/Bitwarden.Sdk/CommandRunner.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Bitwarden.Sdk;
using System.Text.Json;
using System.Text.Json;

namespace Bitwarden.Sdk;

internal class CommandRunner
{

private readonly BitwardenSafeHandle _handle;

internal CommandRunner(BitwardenSafeHandle handle)
Expand Down
10 changes: 5 additions & 5 deletions languages/csharp/Bitwarden.Sdk/ProjectsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal ProjectsClient(CommandRunner commandRunner)

public ProjectResponse Get(Guid id)
{
var command = new Command() { Projects = new ProjectsCommand { Get = new ProjectGetRequest { Id = id } } };
var command = new Command { Projects = new ProjectsCommand { Get = new ProjectGetRequest { Id = id } } };
var result = _commandRunner.RunCommand<ResponseForProjectResponse>(command);

if (result is { Success: true })
Expand All @@ -24,7 +24,7 @@ public ProjectResponse Get(Guid id)

public ProjectResponse Create(Guid organizationId, string name)
{
var command = new Command()
var command = new Command
{
Projects = new ProjectsCommand
{
Expand All @@ -43,7 +43,7 @@ public ProjectResponse Create(Guid organizationId, string name)

public ProjectResponse Update(Guid id, Guid organizationId, string name)
{
var command = new Command()
var command = new Command
{
Projects = new ProjectsCommand
{
Expand All @@ -62,7 +62,7 @@ public ProjectResponse Update(Guid id, Guid organizationId, string name)

public ProjectsDeleteResponse Delete(Guid[] ids)
{
var command = new Command()
var command = new Command
{
Projects = new ProjectsCommand { Delete = new ProjectsDeleteRequest { Ids = ids } }
};
Expand All @@ -78,7 +78,7 @@ public ProjectsDeleteResponse Delete(Guid[] ids)

public ProjectsResponse List(Guid organizationId)
{
var command = new Command()
var command = new Command
{
Projects = new ProjectsCommand { List = new ProjectsListRequest { OrganizationId = organizationId } }
};
Expand Down
13 changes: 5 additions & 8 deletions languages/csharp/Bitwarden.Sdk/SecretsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal SecretsClient(CommandRunner commandRunner)

public SecretResponse Get(Guid id)
{
var command = new Command() { Secrets = new SecretsCommand { Get = new SecretGetRequest { Id = id } } };
var command = new Command { Secrets = new SecretsCommand { Get = new SecretGetRequest { Id = id } } };
var result = _commandRunner.RunCommand<ResponseForSecretResponse>(command);

if (result is { Success: true })
Expand All @@ -25,7 +25,7 @@ public SecretResponse Get(Guid id)
public SecretResponse Create(string key, string value, string note, Guid organizationId,
Guid[] projectIds)
{
var command = new Command()
var command = new Command
{
Secrets = new SecretsCommand
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public SecretResponse Create(string key, string value, string note, Guid organiz
public SecretResponse Update(Guid id, string key, string value, string note, Guid organizationId,
Guid[] projectIds)
{
var command = new Command()
var command = new Command
{
Secrets = new SecretsCommand
{
Expand Down Expand Up @@ -81,10 +81,7 @@ public SecretResponse Update(Guid id, string key, string value, string note, Gui

public SecretsDeleteResponse Delete(Guid[] ids)
{
var command = new Command()
{
Secrets = new SecretsCommand { Delete = new SecretsDeleteRequest { Ids = ids } }
};
var command = new Command { Secrets = new SecretsCommand { Delete = new SecretsDeleteRequest { Ids = ids } } };
var result = _commandRunner.RunCommand<ResponseForSecretsDeleteResponse>(command);

if (result is { Success: true })
Expand All @@ -97,7 +94,7 @@ public SecretsDeleteResponse Delete(Guid[] ids)

public SecretIdentifiersResponse List(Guid organizationId)
{
var command = new Command()
var command = new Command
{
Secrets = new SecretsCommand { List = new SecretIdentifiersRequest { OrganizationId = organizationId } }
};
Expand Down
Binary file modified languages/csharp/Bitwarden.Sdk/bitwarden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bbbfdc6

Please sign in to comment.