Creating your first CodeFactory project

Creating a CodeFactory project requires several steps, including registering the first command. CodeFactory loads the target versions of SDK libraries directly from NuGet, which are automatically pulled down upon the first build of the project. The CodeFactory commands project is the main execution point for all automation, and the CFXPackager utility builds the CFX file used to run CodeFactory automation. To create a project, start Visual Studio, click on "Create a new project," search for "CodeFactory," select "CodeFactory - Commands Library," and name the project. The project and default folder structure will be displayed, including the Project, Dialog, Logic, and Template folders. To add a solution explorer project command to the project, right-click on the project folder, select "Add," choose "New Item...," select "CodeFactory" from Visual C# Items, select "Solution Explorer - Project Command," name the command file, and click "Add." An error message will appear since the CodeFactory SDK NuGet packages have not been downloaded into the project yet, but this is normal. Build the solution to trigger the pull of the NuGet packages, which will remove the syntax errors in the project command. The project creation process is complete.

Full detailed instructions with screenshots are available in our documentation site:

Creating a Project | CodeFactory Platform

CodeFactory SDK Release Notes Summary (1.23050.2)

The SDK Release version 1.23050.2 includes updates for CodeFactory SDK, adding new features and improvements. The release introduces three new methods to IVSActions, allowing easier access to project and support project file types to CSSource models. CSMembers also have two new helper methods to grant direct access to the syntax and to comment out a target member. Additionally, two new container types have been added, supporting version 9 and 10 of the C# programming language, and the property model has been extended to support record types. The container interface has been split into two interfaces, and CsSource Model has been extended with several new properties, including Records, RecordStructures, HostedInProject, and ProjectName.

Automating Repetitive Common Code: Reduction in Delivery Time

In the development of modern applications, there is often a significant amount of "plumbing" code that is responsible for basic operations such as logging, error handling, authorization, and transaction handling. This type of common and repetitive code is essential for the proper functioning of the application, but it seldom delivers functional business features.

One of the primary challenges with this type of code is that it is often the portion of the solutions that teams most often miss or skip over when they are in a hurry. This can lead to delays in delivery time and increased costs for the development team.

CodeFactory, a real-time software delivery tool that runs inside of Visual Studio, offers a solution to this problem by automating the generation of this type of common and repetitive code. By consuming your existing code artifacts, CodeFactory can auto-generate much of the lower-level plumbing code that allows your application to work correctly. This eliminates the need for manual coding and speeds up the delivery process.

Eliminating Copy/Paste Programming: Reduction in Application Defects

Another common practice among development teams is the use of copy/paste programming. This is when code snippets are copied from various sources, such as Stack Overflow, resulting in significant variability in common plumbing code. This approach can lead to increased defects in the application and increased costs for the development team.

CodeFactory offers a solution to this problem by enabling the templatization of patterns and functionality that are intended to be in your application. These CodeFactory templates generate code from your Visual Studio solution and will automatically create the code for your team, eliminating the need for copy/paste programming and reducing the number of defects in the application.

Simplified Code Maintenance: Reduction in Maintenance Costs

Maintaining code is an essential part of the development process. However, it can be a time-consuming and costly task, especially when the person who created a section of code is not available for future updates or maintenance. One of the primary sources of code maintenance inefficiency is inconsistently implemented code. If two developers are given the same problem to solve, they will often use different approaches to solve it. This means that when defects are found in the application or enhancements need to be added, the existing style of development has to be discovered, which takes up valuable time.

With CodeFactory generated code, there is only one style of implemented code. This makes it easy to find and easy to fix by simply updating the CodeFactory template and regenerating all the impacted code sources. This simplifies the code maintenance process and reduces the costs associated with it.

In conclusion, CodeFactory is a powerful tool that can help development teams automate repetitive common code, eliminate copy/paste programming, and simplify code maintenance. By reducing delivery time, reducing application defects, and reducing maintenance costs, CodeFactory can help teams deliver high-quality software on time and within budget.

Using CodeFactory automation to Add Missing Members

CodeFactory's open-source “Add Missing Members” automation aims to implement missing interface members in a specific pattern. It uses Condition Management to confirm target using statements, Namespace Manager to manage type definitions, locates interface members not implemented, and uses source formatting to capture code to be injected into files in Visual Studio. It also updates source code by target location and uses C# models to make implementation decisions. The automation checks for missing members from inherited interfaces, adds Microsoft logging extensions, creates a _logger readonly field and constructor, adds missing using namespaces, and implements missing properties, events and methods with xml documentation, attribute definitions, standard syntax, and logging for entrance and exit points, bounds checking, try-catch blocks, and return statements if necessary.

CodeFactoryExamples/Index.md at main · CodeFactoryLLC/CodeFactoryExamples · GitHub

Code generating tooling re-imagined.

While code-automation tooling is not a new concept, CodeFactory takes a new approach to overcome the limitations of these other tools. Historically, code generating tool kits have had three significant drawbacks which limit their overall usefulness. These include: 1) limited template authoring flexibility; 2) a dependence on bundled run-time code, libraries and/or code reflection and; 3) are best suited for either building new systems from the ground up or for modernizing older systems, but not both . These tool kits limit your team to building code the way the tool creator envisioned.

CodeFactory offers a fully supported open-source Authoring version of the product (CodeFactory SDK) which allows you to customize ANY code automation tasks to conform with your desired architecture and/or application standards and evolve as better methods emerge. Also, CodeFactory does not require you to bundle run time libraries or alter your code or in any way to take advantage of its features. By generating code 100% at >design time< we eliminate the performance overhead of reflection and even support the ability to version different automation templates per solution or team depending on your needs. Whether you need to extend the life of a critical system with some complex refactoring or have a new system to design, CodeFactory is well-suited for either need.

Time saved from letting CodeFactory automatically generate and refactor plumbing code, frees up the creative talents of the development team to focus on the more complex and innovative aspects of the solution design.

Common Delivery Framework Roadmap Released

The Common Delivery Framework project will be extended to take advantage of CodeFactory v1.5 and the updated workflow automation. In the 2.0 release of Common Delivery Framework the following capabilities will be included:

  • Managed Exceptions - Standardized exception management using a standard set of managed exceptions.

  • Managed Dependency Injection - Standardized pattern for setting dependency injection in libraries. Auto generation of transient service registration by library.

  • Managed Logging - Standardized logging extensions that provide member and line number information when logging. Also provides a hook for automation to inject logging.

  •  Architecture Configuration - Map projects in Visual Studio to target layers of your applications architecture. Configure automation to trigger based on target objects in projects executing CodeFactory commands.

  • Member Generation - Generation of members in classes and interfaces based on CodeFactory automation.

  • Bounds Checking Generation - Auto generation of bounds checking logic in methods as members are being generated.

  • Logging Generation - Auto generation of enter, exit, and exception management logging in members that are being generated.

  • Model Generation Application Models - Auto generation of application POCO objects from Entity framework Objects.

  • Entity Framework Transform Logic - Auto generation of logic to create application models.
    Auto generation of logic to create entity framework models  from application models.

  • Model Generation GRPC Service Models - Auto generation of POCO models to support GRPC

  • Auto generation of logic to create application models from GRPC models. - Auto generation of logic to create GRPC models from application models.

  •  GRPC Service Layer Generation - Auto generation of GRPC services from either a logic implementation or a repository implementation. This will include full model transformation, and all error management.

  • GRPC Abstraction Layer Generation - Auto generation of a GRPC abstraction layer from a GRPC service. This will include the mapping of GRPC models to and from application models. This will include the ability to send and raise managed exceptions as part of the abstraction.

  •  Web API Service Layer Generation - Auto generation of web API service controllers from either a logic implementation or a repository implementation. This will include full model transformation, and all error management.

  • Web API Abstraction Layer Generation - Auto generation of a web API service abstraction layer from a rest service hosted in the solution. This will include the mapping JSON to and from application models. This will include the ability to send and raise managed exceptions as part of the abstraction.

  •  Entity Framework POCO Repository Generation - Ability to select Entity Framework POCO object and auto generate repository with the base definition and create, update, and delete implementations to be created automatically. This will include creation of the interface that defines the repository and the repository itself.

 —————————

bookmark the Common Delivery Framework on Github today and get the latest update as soon as it is released!

.NET Conf Announcement

CodeFactory, now available for Visual Studio ’22, is the first design-time code generation extension to support custom automation commands authored by YOU. Eliminate the headaches of writing, testing & maintaining handwritten plumbing code. Need to transform or modernize existing functionality of a legacy ASP.NET application to leverage new .NET 6 capabilities quickly? No problem! Use the CodeFactory SDK to author custom auto-scaffolding and transformation commands specific to your needs. There’s plenty of well-documented CodeFactory templates, tutorials, and open-source reference projects available to get you started. Download your free copy of CodeFactory today.

Automating Pattern or Architectural Standards Compliance

Anybody interested in implementing sustainable Pattern and/or Architectural standards compliance can utilize CodeFactory to auto-scaffold out their preferred organizational design standards into a new application (or refactored one) using CodeFactory automation. Starting with our open-source Common Delivery Framework, a modified version could be built out that aligns specifically with alternate principles and tenets (such as DDD and/or CQRS+ES).

Updated: Common Delivery Framework

We just released a new version of our #CommonDeliveryFramework.

https://github.com/CodeFactoryLLC/CommonDeliveryFramework/tree/Net

This framework contains Exception Type definitions, Message Type definitions, ASP.NET Types (Controller, etc.) that have been pre-set to be consumed by CodeFactory. Any Template author can simply import the CDF framework portion that they are most interested in leveraging for their own automation needs at the following NuGet locations:

https://www.nuget.org/packages/CommonDeliveryFramework/1.20310.1-NET5RC2

https://www.nuget.org/packages/CommonDeliveryFramework.Net.Aspnet/1.20310.1-NET5RC2

https://www.nuget.org/packages/CommonDeliveryFramework.Automation/1.0.203101-RC1

Mastodon