Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplementation of in memory profile support #180

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*]

#Our EditorConfig


indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.cs]
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true

39 changes: 38 additions & 1 deletion SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsOptionPage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell;
using SmartCmdArgs.Helper;
using System;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -45,6 +46,19 @@ public enum EnableBehaviour
[Description("Enable by default (old behaviour)")]
EnableByDefault,
}
[Flags]
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum SetActiveProfileBehavior
{
[Description("Never, due to a bug in virtual profiles you will have to reselect Smart CLI Args every time you open a project")]
Never = 1 << 0,
[Description("On Smart CLI Arg tree changed (ie option checked)")]
OnTreeChanged = 1 << 1,
[Description("On first run/debug")]
OnRun = 1 << 2,
[Description("On Smart CLI Arg option checked or first run/debug")]
OnCheckedOrRun = OnTreeChanged | OnRun
}

public class CmdArgsOptionPage : DialogPage, INotifyPropertyChanged
{
Expand All @@ -64,6 +78,7 @@ public CmdArgsOptionPage() : base()
}

private EnableBehaviour _enableBehaviour;
private SetActiveProfileBehavior _setActiveProfileBehavior;
private RelativePathRootOption _relativePathRoot;

private bool _useMonospaceFont;
Expand All @@ -78,6 +93,7 @@ public CmdArgsOptionPage() : base()
private bool _manageWorkingDirectories;
private bool _manageLaunchApplication;
private bool _vcsSupportEnabled;
private bool _useCpsVirtualProfile;
private bool _useSolutionDir;
private bool _macroEvaluationEnabled;

Expand All @@ -91,6 +107,16 @@ public EnableBehaviour EnableBehaviour
set => SetAndNotify(value, ref _enableBehaviour);
}

[Category("Settings Defaults")]
[DisplayName("Set Active Profile Behavior")]
[Description("When we should automatically make ourselves the active profile")]
[DefaultValue(SetActiveProfileBehavior.OnTreeChanged)]
public SetActiveProfileBehavior SetActiveProfileBehavior
{
get => _setActiveProfileBehavior;
set => SetAndNotify(value, ref _setActiveProfileBehavior);
}

[Category("General")]
[DisplayName("Relative path root")]
[Description("Sets the base path that is used to resolve relative paths for the open/reveal file/folder context menu option.")]
Expand All @@ -111,6 +137,7 @@ public bool UseMonospaceFont
set => SetAndNotify(value, ref _useMonospaceFont);
}


[Category("Appearance")]
[DisplayName("Display Tags for CLAs")]
[Description("If enabled the item tag 'CLA' is displayed for Command Line Arguments. Normally the tag 'ENV' is only displayed for environment varibales.")]
Expand Down Expand Up @@ -201,6 +228,16 @@ public bool VcsSupportEnabled
set => SetAndNotify(value, ref _vcsSupportEnabled);
}

[Category("Settings Defaults")]
[DisplayName("Use CPS Virtual Profile")]
[Description("If enabled a virtual profile is created for CPS projects and only this profile is changed by the extension.")]
[DefaultValue(false)]
public bool UseCpsVirtualProfile
{
get => _useCpsVirtualProfile;
set => SetAndNotify(value, ref _useCpsVirtualProfile);
}

[Category("Settings Defaults")]
[DisplayName("Use Solution Directory")]
[Description("If enabled all arguments of every project will be stored in a single file next to the *.sln file. (Only if version control support is enabled)")]
Expand Down
15 changes: 9 additions & 6 deletions SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsPackage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <copyright file="CmdArgsPackage.cs" company="Company">
// Copyright (c) Company. All rights reserved.
// </copyright>
Expand Down Expand Up @@ -69,7 +69,8 @@ public sealed class CmdArgsPackage : AsyncPackage
private ISuoDataService suoDataService;
private ILifeCycleService lifeCycleService;
private IVsEventHandlingService vsEventHandling;
private IFileStorageEventHandlingService fileStorageEventHandling;
private IFileStorageEventHandlingService fileStorageEventHandling;
private ICpsProjectConfigService cpsProjectConfigService;

private ToolWindowViewModel toolWindowViewModel;
private TreeViewModel treeViewModel;
Expand Down Expand Up @@ -105,7 +106,8 @@ public CmdArgsPackage()
suoDataService = ServiceProvider.GetRequiredService<ISuoDataService>();
lifeCycleService = ServiceProvider.GetRequiredService<ILifeCycleService>();
vsEventHandling = ServiceProvider.GetRequiredService<IVsEventHandlingService>();
fileStorageEventHandling = ServiceProvider.GetRequiredService<IFileStorageEventHandlingService>();
fileStorageEventHandling = ServiceProvider.GetRequiredService<IFileStorageEventHandlingService>();
cpsProjectConfigService = ServiceProvider.GetRequiredService<ICpsProjectConfigService>();
}

protected override void Dispose(bool disposing)
Expand Down Expand Up @@ -170,7 +172,8 @@ private ServiceProvider ConfigureServices()
services.AddLazySingleton(x => GetDialogPage<CmdArgsOptionPage>());
services.AddLazySingleton<SettingsViewModel>();
services.AddLazySingleton<ToolWindowViewModel>();
services.AddLazySingleton<TreeViewModel>();
services.AddLazySingleton<TreeViewModel>();
services.AddLazySingleton<ICpsProjectConfigService, CpsProjectConfigService>();
services.AddLazySingleton<IProjectConfigService, ProjectConfigService>();
services.AddSingleton<IVisualStudioHelperService, VisualStudioHelperService>();
services.AddSingleton<IFileStorageService, FileStorageService>();
Expand Down Expand Up @@ -262,9 +265,9 @@ public List<string> GetLaunchProfiles(Guid projGuid)
var project = vsHelper.HierarchyForProjectGuid(projGuid);

List<string> launchProfiles = null;
if (project?.IsCpsProject() == true)
if (project?.SupportsLaunchProfiles() == true)
{
launchProfiles = CpsProjectSupport.GetLaunchProfileNames(project.GetProject())?.ToList();
launchProfiles = cpsProjectConfigService.GetLaunchProfileNames(project.GetProject())?.ToList();
}

return launchProfiles ?? new List<string>();
Expand Down
Loading