Skip to content

Commit 4cb2297

Browse files
committed
Feburary updates to support command that executes as soon as the solution loaded. Bug fix to handle double documentation comments added due to changes on how documentation is loaded.
1 parent 7824eaa commit 4cb2297

File tree

9 files changed

+160
-4
lines changed

9 files changed

+160
-4
lines changed

src/CodeFactoryVisualStudio/CodeFactory.DotNet/CodeFactory.DotNet.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@
189189
<Compile Include="WellKnownLanguageType.cs" />
190190
</ItemGroup>
191191
<ItemGroup>
192-
<None Include="CodeFactoryRuntimeSigner.snk" />
193192
<None Include="CodeFactorySigner.snk" />
194193
<None Include="packages.config" />
195194
</ItemGroup>

src/CodeFactoryVisualStudio/CodeFactory.Formatting.CSharp/DocumentationExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public static string CSharpFormatDocumentationLine(this string source)
5050
if (string.IsNullOrEmpty(source)) return null;
5151
var trimmed = source.Trim();
5252
if (trimmed.Contains("<member")) return null;
53-
return trimmed.Contains("</member") ? null : $"///{trimmed}";
53+
if (trimmed.Contains("</member")) return null;
54+
return trimmed.Contains("///") ? trimmed : $"///{trimmed}";
5455
}
5556
}
5657
}

src/CodeFactoryVisualStudio/CodeFactory.Logging/CodeFactory.Logging.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
<Compile Include="Properties\AssemblyInfo.cs" />
7979
</ItemGroup>
8080
<ItemGroup>
81-
<None Include="CodeFactoryRuntimeSigner.snk" />
8281
<None Include="CodeFactorySigner.snk" />
8382
</ItemGroup>
8483
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

src/CodeFactoryVisualStudio/CodeFactory.VisualStudio/CodeFactory.VisualStudio.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@
7676
<Compile Include="AssemblyCFEnvironment.cs" />
7777
<Compile Include="AssemblyCFSdkVersion.cs" />
7878
<Compile Include="CSharpSourceExtensions.cs" />
79+
<Compile Include="IDE\ISolutionLoadCommand.cs" />
80+
<Compile Include="IDE\SolutionLoadCommandBase.cs" />
7981
<Compile Include="IVsEnvironmentActions.cs" />
82+
<Compile Include="IVsEnvironmentCommand.cs" />
8083
<Compile Include="IVsProjectFramework.cs" />
8184
<Compile Include="PathHelper.cs" />
8285
<Compile Include="FileHelper.cs" />
@@ -140,6 +143,7 @@
140143
<DependentUpon>VisualStudioMessages.resx</DependentUpon>
141144
</Compile>
142145
<Compile Include="VisualStudioModelType.cs" />
146+
<Compile Include="VsEnvironmentCommandBase.cs" />
143147
<Compile Include="VsCommandBase.cs" />
144148
<Compile Include="VsCommandType.cs" />
145149
<Compile Include="VsCSharpSource.cs" />
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//*****************************************************************************
2+
//* Code Factory SDK
3+
//* Copyright (c) 2023 CodeFactory, LLC
4+
//*****************************************************************************
5+
6+
namespace CodeFactory.VisualStudio.IDE
7+
{
8+
/// <summary>
9+
/// Code factory command that triggers once the solution has been loaded. Will only be called once.
10+
/// </summary>
11+
public interface ISolutionLoadCommand : IVsEnvironmentCommand<VsSolution>
12+
{
13+
//Intentionally blank
14+
}
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//*****************************************************************************
2+
//* Code Factory SDK
3+
//* Copyright (c) 2023 CodeFactory, LLC
4+
//*****************************************************************************
5+
6+
using CodeFactory.Logging;
7+
8+
namespace CodeFactory.VisualStudio.IDE
9+
{
10+
/// <summary>
11+
/// Base implementation of the solution explorer command <see cref="ISolutionLoadCommand"/>
12+
/// </summary>
13+
public abstract class SolutionLoadCommandBase: VsEnviromentCommandBase<VsSolution>,ISolutionLoadCommand
14+
{
15+
16+
/// <inheritdoc />
17+
protected SolutionLoadCommandBase(ILogger logger, IVsActions vsActions,string commandTitle, string commandDescription) : base(logger,vsActions,VsCommandType.IDESolutionLoad,commandTitle,commandDescription)
18+
{
19+
//Intentionally blank
20+
}
21+
}
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//*****************************************************************************
2+
//* Code Factory SDK
3+
//* Copyright (c) 2023 CodeFactory, LLC
4+
//*****************************************************************************
5+
using System.Threading.Tasks;
6+
7+
namespace CodeFactory.VisualStudio
8+
{
9+
10+
/// <summary>
11+
/// Base implementation for all code factory commands that are directly executed by the Visual Studio Enviornment.
12+
/// </summary>
13+
/// <typeparam name="TModel">Target code factory model to be provided for the command.</typeparam>
14+
public interface IVsEnvironmentCommand<TModel>: IVsCommandInformation where TModel : class
15+
{
16+
/// <summary>
17+
/// Code factory framework calls this method when the command has been executed.
18+
/// </summary>
19+
/// <param name="result">The code factory model that has generated and provided to the command to process.</param>
20+
Task ExecuteCommandAsync(TModel result);
21+
22+
/// <summary>
23+
/// Global visual studio commands that can be accessed from this visual studio command.
24+
/// </summary>
25+
IVsActions VisualStudioActions { get; }
26+
}
27+
}

src/CodeFactoryVisualStudio/CodeFactory.VisualStudio/VsCommandType.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//*****************************************************************************
22
//* Code Factory SDK
3-
//* Copyright (c) 2020 CodeFactory, LLC
3+
//* Copyright (c) 2023 CodeFactory, LLC
44
//*****************************************************************************
55

66
namespace CodeFactory.VisualStudio
@@ -45,6 +45,11 @@ public enum VsCommandType
4545
/// </summary>
4646
SolutionExplorerCSharpSourceCode = 6,
4747

48+
/// <summary>
49+
/// IDE level command that is fired once the solution has been loaded. Will only be triggered once the solution is loaded.
50+
/// </summary>
51+
IDESolutionLoad = 7,
52+
4853
/// <summary>
4954
/// The command type is unknown
5055
/// </summary>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//*****************************************************************************
2+
//* Code Factory SDK
3+
//* Copyright (c) 2023 CodeFactory, LLC
4+
//*****************************************************************************
5+
using System.Threading.Tasks;
6+
using CodeFactory.Logging;
7+
8+
namespace CodeFactory.VisualStudio
9+
{
10+
/// <summary>
11+
/// Base implementation for a environment command that supports integration with the Visual studio IDE environment directly.
12+
/// </summary>
13+
/// <typeparam name="TModel">The target visual studio model type to be returned from the visual studio environment command.</typeparam>
14+
public abstract class VsEnviromentCommandBase<TModel> : IVsEnvironmentCommand<TModel> where TModel : class
15+
{
16+
/// <summary>
17+
/// Backing field for the property <see cref="CommandTitle"/>
18+
/// </summary>
19+
protected readonly string _commandTitle;
20+
21+
/// <summary>
22+
/// Backing field for the property <see cref="CommandDescription"/>
23+
/// </summary>
24+
protected readonly string _commandDescription;
25+
26+
/// <summary>
27+
/// Backing field for the property <see cref="CommandType"/>
28+
/// </summary>
29+
private readonly VsCommandType _commandType;
30+
31+
/// <summary>
32+
/// Logging method that is used by the command to log to the code factory logging framework.
33+
/// </summary>
34+
protected readonly ILogger _logger;
35+
36+
/// <summary>
37+
/// Backing field for the property <see cref="VisualStudioActions"/>
38+
/// </summary>
39+
private readonly IVsActions _visualStudioActions;
40+
41+
/// <summary>
42+
/// Base constructor used it initialize a visual studio command.
43+
/// </summary>
44+
/// <param name="logger">The code factory logger to be used by the logger.</param>
45+
/// <param name="commands">The global visual studio commands that can be used by this visual studio command.</param>
46+
/// <param name="commandType">The target type of command being created. </param>
47+
/// <param name="commandTitle">The title displayed in visual studio for this command.</param>
48+
/// <param name="commandDescription">A brief description of the purpose of this command.</param>
49+
protected VsEnviromentCommandBase(ILogger logger, IVsActions commands, VsCommandType commandType,string commandTitle, string commandDescription)
50+
{
51+
_logger = logger;
52+
_commandType = commandType;
53+
_visualStudioActions = commands;
54+
_commandTitle = commandTitle;
55+
_commandDescription = commandDescription;
56+
}
57+
58+
/// <summary>
59+
/// Action title that will be displayed within visual studio.
60+
/// </summary>
61+
public string CommandTitle => _commandTitle;
62+
63+
/// <summary>
64+
/// An optional discription that discribes what this factory command is intended for.
65+
/// </summary>
66+
public string CommandDescription => _commandDescription;
67+
68+
/// <summary>
69+
/// The target type of command that is being loaded.
70+
/// </summary>
71+
public VsCommandType CommandType => _commandType;
72+
73+
/// <summary>
74+
/// Global visual studio commands that can be accessed from this visual studio command.
75+
/// </summary>
76+
public IVsActions VisualStudioActions => _visualStudioActions;
77+
78+
/// <summary>
79+
/// Code factory framework calls this method when the command has been executed.
80+
/// </summary>
81+
/// <param name="result">The code factory model that has generated and provided to the command to process.</param>
82+
public abstract Task ExecuteCommandAsync(TModel result);
83+
}
84+
}

0 commit comments

Comments
 (0)