Skip to content

Commit

Permalink
Merge pull request #50 from SuessLabs/feature/StaticOptions
Browse files Browse the repository at this point in the history
Options Class Cleanup
  • Loading branch information
DamianSuess authored Feb 14, 2023
2 parents c27e003 + 177540a commit b995658
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 159 deletions.
6 changes: 6 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

This document contains the release information for the project.

### 2.0.2 (Prev-2)

* Fixed: As per #53, cleaned up exponential Build status messages.
* Added: Enabled quick access to Linux Debugger's Options dialog
* Update: Refactored options mechanism in prep for custom profiles.

### 2.0.1 (Prev-1)

* Added: Option to set output window focus to Linux Debugger, default=`false`. (PR #46)
Expand Down
4 changes: 2 additions & 2 deletions sandbox/GuiNet5/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public static AppBuilder BuildAvaloniaApp() => AppBuilder
.UsePlatformDetect()
.With(new X11PlatformOptions
{
EnableMultiTouch = true,
UseDBusMenu = true,
EnableMultiTouch = false,
UseDBusMenu = false,
})
.With(new Win32PlatformOptions
{
Expand Down
2 changes: 1 addition & 1 deletion sandbox/GuiNet6/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static AppBuilder BuildAvaloniaApp() => AppBuilder
.With(new X11PlatformOptions
{
EnableMultiTouch = true,
UseDBusMenu = true,
UseDBusMenu = false,
})
.With(new Win32PlatformOptions
{
Expand Down
61 changes: 21 additions & 40 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,8 @@ root = true
[*]
end_of_line = crlf
indent_style = space
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 2
indent_size = 2
csharp_indent_labels = one_less_than_current
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = when_multiline:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent

[*.{c,cpp,h}]
indent_style = space
Expand Down Expand Up @@ -176,6 +147,9 @@ csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false

csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion

Expand Down Expand Up @@ -207,21 +181,21 @@ dotnet_style_require_accessibility_modifiers = for_non_interface_members
dotnet_style_readonly_field = true

# Expression-level preferences
dotnet_style_coalesce_expression = true
dotnet_style_collection_initializer = true
dotnet_style_explicit_tuple_names = true
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_namespace_match_folder = true
dotnet_style_null_propagation = true
dotnet_style_object_initializer = true
dotnet_style_null_propagation = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_prefer_auto_properties = true
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_compound_assignment = true
dotnet_style_prefer_conditional_expression_over_assignment = true
dotnet_style_prefer_conditional_expression_over_return = true
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_prefer_inferred_anonymous_type_member_names = true
dotnet_style_prefer_inferred_tuple_names = true
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
dotnet_style_prefer_simplified_boolean_expressions = true
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:silent
dotnet_style_prefer_simplified_interpolation = true

# Parameter preferences
Expand Down Expand Up @@ -334,6 +308,13 @@ dotnet_diagnostic.IDE0046.severity = none
# IDE0058: Expression value is never used
# csharp_style_unused_value_expression_statement_preference = discard_variable
dotnet_diagnostic.IDE0058.severity = none
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent

## Code Quality Rules
# CA1031: Do not catch general exception types
Expand Down
34 changes: 18 additions & 16 deletions src/VsLinuxDebugger/Commands.Impl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,30 +158,32 @@ private void SetMenuTextAndVisibility(object sender, EventArgs e)

private UserOptions ToUserOptions()
{
DebuggerPackage VsixPackage = _package as DebuggerPackage;

return new UserOptions
{
DeleteLaunchJsonAfterBuild = Settings.DeleteLaunchJsonAfterBuild,
DeleteLaunchJsonAfterBuild = VsixPackage.VsixOptions.DeleteLaunchJsonAfterBuild,

HostIp = Settings.HostIp,
HostPort = Settings.HostPort,
HostIp = VsixPackage.VsixOptions.HostIp,
HostPort = VsixPackage.VsixOptions.HostPort,

LocalPLinkPath = Settings.LocalPLinkPath,
LocalSwitchLinuxDbgOutput = Settings.LocalSwitchLinuxDbgOutput,
LocalPLinkPath = VsixPackage.VsixOptions.PLinkPath,
LocalSwitchLinuxDbgOutput = VsixPackage.VsixOptions.SwitchLinuxDbgOutput,

RemoteDebugDisplayGui = Settings.RemoteDebugDisplayGui,
RemoteDeployBasePath = Settings.RemoteDeployBasePath,
RemoteDotNetPath = Settings.RemoteDotNetPath,
RemoteVsDbgBasePath = Settings.RemoteVsDbgBasePath,
RemoteDebugDisplayGui = VsixPackage.VsixOptions.RemoteDebugDisplayGui,
RemoteDeployBasePath = VsixPackage.VsixOptions.RemoteDeployBasePath,
RemoteDotNetPath = VsixPackage.VsixOptions.RemoteDotNetPath,
RemoteVsDbgBasePath = VsixPackage.VsixOptions.RemoteVsDbgRootPath,

UseCommandLineArgs = Settings.UseCommandLineArgs,
UseCommandLineArgs = VsixPackage.VsixOptions.UseCommandLineArgs,
//// UsePublish = Settings.UsePublish,

UserPrivateKeyEnabled = Settings.UserPrivateKeyEnabled,
UserPrivateKeyPath = Settings.UserPrivateKeyPath,
UserPrivateKeyPassword = Settings.UserPrivateKeyPassword,
UserName = Settings.UserName,
UserPass = Settings.UserPass,
UserGroupName = Settings.UserGroupName,
UserPrivateKeyEnabled = VsixPackage.VsixOptions.UserPrivateKeyEnabled,
UserPrivateKeyPath = VsixPackage.VsixOptions.UserPrivateKeyPath,
UserPrivateKeyPassword = VsixPackage.VsixOptions.UserPrivateKeyPassword,
UserName = VsixPackage.VsixOptions.UserName,
UserPass = VsixPackage.VsixOptions.UserPass,
UserGroupName = VsixPackage.VsixOptions.UserGroupName,
};
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/VsLinuxDebugger/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ private Commands(AsyncPackage package, OleMenuCommandService commandService)
/// <summary>Gets the service provider from the owner package.</summary>
private Microsoft.VisualStudio.Shell.IAsyncServiceProvider ServiceProvider => this._package;

private DebuggerPackage Settings => _package as DebuggerPackage;

/// <summary>Initializes the singleton instance of the command.</summary>
/// <param name="package">Owner package, not null.</param>
public static async Task InitializeAsync(AsyncPackage package)
Expand Down
6 changes: 3 additions & 3 deletions src/VsLinuxDebugger/Core/LaunchBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

namespace VsLinuxDebugger.Core
{
// TODO: Combine with UserOptions to make life easier.
/// <summary>LaunchBuilder class for serialization.</summary>
public class LaunchBuilder
{
public const string AdapterFileName = "launch.json";

private UserOptions _opts;

public LaunchBuilder(DTE2 dte, Project dteProject, UserOptions o)
public LaunchBuilder(DTE2 dte, Project dteProject, UserOptions userOptions)
{
ThreadHelper.ThrowIfNotOnUIThread();

_opts = o;
_opts = userOptions;

AssemblyName = dteProject.Properties.Item("AssemblyName").Value.ToString();
ProjectConfigName = dteProject.ConfigurationManager.ActiveConfiguration.ConfigurationName;
Expand Down
29 changes: 24 additions & 5 deletions src/VsLinuxDebugger/Core/RemoteDebugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public async Task<bool> BeginAsync(BuildOptions buildOptions)
}
}

using (var ssh = new SshTool(_options, _launchBuilder))
var remoteInfo = GetRemoteConnectionInfo();

using (var ssh = new SshTool(remoteInfo))
{
var success = await ssh.ConnectAsync();
if (!success)
Expand All @@ -72,13 +74,15 @@ public async Task<bool> BeginAsync(BuildOptions buildOptions)
return false;
}

await ssh.TryInstallVsDbgAsync();
await ssh.MakeDeploymentFolderAsync();
await ssh.CleanDeploymentFolderAsync();
var vsDbgFolder = LinuxPath.Combine(_options.RemoteVsDbgBasePath, Constants.VS2022);

await ssh.TryInstallVsDbgAsync(vsDbgFolder);
await ssh.MakeDeploymentFolderAsync(_options.RemoteDeployBasePath);
await ssh.CleanFolderAsync(_launchBuilder.RemoteDeployProjectFolder);

if (buildOptions.HasFlag(BuildOptions.Deploy))
{
await ssh.UploadFilesAsync();
await ssh.UploadFilesAsync(_launchBuilder.OutputDirFullPath, _launchBuilder.RemoteDeployProjectFolder);
}
////else if (buildOptions.HasFlag(BuildOptions.Publish))
////{
Expand Down Expand Up @@ -235,6 +239,21 @@ private bool Initialize()
return true;
}

private SshConnectionInfo GetRemoteConnectionInfo()
{
return new SshConnectionInfo
{
Host = _options.HostIp,
Port = _options.HostPort,
UserGroup = _options.UserGroupName,
UserName = _options.UserName,
UserPass = _options.UserPass,
PrivateKeyEnabled = _options.UserPrivateKeyEnabled,
PrivateKeyPath = _options.UserPrivateKeyPath,
PrivateKeyPassword = _options.UserPrivateKeyPassword,
};
}

private bool IsCSharpProject(Project vsProject)
{
ThreadHelper.ThrowIfNotOnUIThread();
Expand Down
22 changes: 22 additions & 0 deletions src/VsLinuxDebugger/Core/SshConnectionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace VsLinuxDebugger.Core
{
public struct SshConnectionInfo
{
public string Host { get; set; }

public int Port { get; set; }

/// <summary>User's Group (if applicable).</summary>
public string UserGroup { get; set; }

public string UserName { get; set; }

public string UserPass { get; set; }

public bool PrivateKeyEnabled { get; set; }

public string PrivateKeyPath { get; set; }

public string PrivateKeyPassword { get; set; }
}
}
Loading

0 comments on commit b995658

Please sign in to comment.