-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from CodeFactoryLLC/StandardNDF
Standard NDF initial release
- Loading branch information
Showing
7 changed files
with
449 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...odeFactory.Automation.Standard.NDF.Logic/CodeFactory.Automation.Standard.NDF.Logic.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{CF0F98B6-E6C9-4BBA-B61F-20E00260676F}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CodeFactory.Automation.Standard.NDF.Logic</RootNamespace> | ||
<AssemblyName>CodeFactory.Automation.Standard.NDF.Logic</AssemblyName> | ||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<StartAction>Program</StartAction> | ||
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="CodeFactory.WinVs.SDK" Version="2.23157.1-PreRelease" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
<Reference Include="System.Xaml" /> | ||
<Reference Include="WindowsBase" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> --> | ||
</Project> |
39 changes: 39 additions & 0 deletions
39
src/Standard/NDF/CodeFactory.Automation.Standard.NDF.Logic/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using CodeFactory.WinVs; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("CodeFactory.Automation.Standard.NDF.Logic")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("CodeFactory.Automation.Standard.NDF.Logic")] | ||
[assembly: AssemblyCopyright("Copyright © 2023")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("cf0f98b6-e6c9-4bba-b61f-20e00260676f")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
[assembly: AssemblyCFEnvironment("CFVSW")] | ||
[assembly: AssemblyCFSdkVersion("2.23157.0.1")] |
123 changes: 123 additions & 0 deletions
123
src/Standard/NDF/CodeFactory.Automation.Standard.NDF/AddMissingMembersNDF.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
using CodeFactory.WinVs; | ||
using CodeFactory.WinVs.Commands; | ||
using CodeFactory.WinVs.Commands.SolutionExplorer; | ||
using CodeFactory.WinVs.Logging; | ||
using CodeFactory.WinVs.Models.CSharp; | ||
using CodeFactory.WinVs.Models.CSharp.Builder; | ||
using CodeFactory.WinVs.Models.ProjectSystem; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using CodeFactory.Automation.Standard.Logic; | ||
|
||
namespace CodeFactory.Automation.Standard | ||
{ | ||
/// <summary> | ||
/// Code factory command for automation of a C# document when selected from a project in solution explorer. | ||
/// </summary> | ||
public class AddMissingMembers : CSharpSourceCommandBase | ||
{ | ||
private static readonly string commandTitle = "Add Missing Interface Members"; | ||
private static readonly string commandDescription = "Adds interface members that are missing from the implementation of the class."; | ||
|
||
/// <summary> | ||
/// Name of the Microsoft logging library. | ||
/// </summary> | ||
private const string MicrosoftLoggingNamespace = "Microsoft.Extensions.Logging"; | ||
|
||
#pragma warning disable CS1998 | ||
|
||
/// <inheritdoc /> | ||
public AddMissingMembers(ILogger logger, IVsActions vsActions) : base(logger, vsActions, commandTitle, commandDescription) | ||
{ | ||
//Intentionally blank | ||
} | ||
|
||
#region External Configuration | ||
|
||
/// <summary> | ||
/// The fully qualified name of the command to be used with configuration. | ||
/// </summary> | ||
public static string Type = typeof(AddMissingMembers).FullName; | ||
|
||
/// <summary> | ||
/// Loads the external configuration definition for this command. | ||
/// </summary> | ||
/// <returns>Will return the command configuration or null if this command does not support external configurations.</returns> | ||
public override ConfigCommand LoadExternalConfigDefinition() | ||
{ | ||
return null; | ||
} | ||
#endregion | ||
|
||
#region Overrides of VsCommandBase<IVsCSharpDocument> | ||
|
||
/// <summary> | ||
/// Validation logic that will determine if this command should be enabled for execution. | ||
/// </summary> | ||
/// <param name="result">The target model data that will be used to determine if this command should be enabled.</param> | ||
/// <returns>Boolean flag that will tell code factory to enable this command or disable it.</returns> | ||
public override async Task<bool> EnableCommandAsync(VsCSharpSource result) | ||
{ | ||
//Result that determines if the command is enabled and visible in the context menu for execution. | ||
bool isEnabled = false; | ||
|
||
try | ||
{ | ||
//Getting the first class in the source code file. | ||
var sourceClass = result.SourceCode?.Classes?.FirstOrDefault(); | ||
|
||
//enable if only a class was found. | ||
isEnabled = sourceClass != null; | ||
|
||
//If enabled if no interface members are missing then do not show. | ||
if (isEnabled) isEnabled = sourceClass.GetMissingInterfaceMembers().Any(); | ||
|
||
} | ||
catch (Exception unhandledError) | ||
{ | ||
_logger.Error($"The following unhandled error occurred while checking if the solution explorer C# document command {commandTitle} is enabled. ", | ||
unhandledError); | ||
isEnabled = false; | ||
} | ||
|
||
return isEnabled; | ||
} | ||
|
||
/// <summary> | ||
/// Code factory framework calls this method when the command has been executed. | ||
/// </summary> | ||
/// <param name="result">The code factory model that has generated and provided to the command to process.</param> | ||
public override async Task ExecuteCommandAsync(VsCSharpSource result) | ||
{ | ||
try | ||
{ | ||
//Getting the hosting project | ||
var project = await result.GetHostingProjectAsync() | ||
?? throw new CodeFactoryException($"Cannot load the project information for C# source code file '{result.Name}' cannot add members."); | ||
|
||
var references = await project.GetProjectReferencesAsync(); | ||
|
||
var hasLogging = references.Any(r => r.Name.StartsWith(MicrosoftLoggingNamespace)); | ||
|
||
var sourceClass = result?.SourceCode?.Classes?.FirstOrDefault() | ||
?? throw new CodeFactoryException( | ||
"The class could not be loaded cannot add members."); | ||
|
||
var updatedClass = await VisualStudioActions.AddMissingMembersStandardAsync(result.SourceCode, sourceClass, hasLogging); | ||
|
||
} | ||
catch (Exception unhandledError) | ||
{ | ||
_logger.Error($"The following unhandled error occurred while executing the solution explorer C# document command {commandTitle}. ", | ||
unhandledError); | ||
|
||
} | ||
|
||
} | ||
|
||
#endregion | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...andard/NDF/CodeFactory.Automation.Standard.NDF/CodeFactory.Automation.Standard.NDF.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{DF91E081-52B7-4698-AB4A-9ABAE2DBEEBE}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CodeFactory.Automation.Standard.NDF</RootNamespace> | ||
<AssemblyName>CodeFactory.Automation.Standard.NDF</AssemblyName> | ||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<StartAction>Program</StartAction> | ||
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="CodeFactory.WinVs.SDK" Version="2.23157.1-PreRelease" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
<Reference Include="System.Xaml" /> | ||
<Reference Include="WindowsBase" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> --> | ||
</Project> |
39 changes: 39 additions & 0 deletions
39
src/Standard/NDF/CodeFactory.Automation.Standard.NDF/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using CodeFactory.WinVs; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("CodeFactory.Automation.Standard.NDF")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("CodeFactory.Automation.Standard.NDF")] | ||
[assembly: AssemblyCopyright("Copyright © 2023")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("df91e081-52b7-4698-ab4a-9abae2dbeebe")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
[assembly: AssemblyCFEnvironment("CFVSW")] | ||
[assembly: AssemblyCFSdkVersion("2.23157.0.1")] |
Oops, something went wrong.