NiceLuc / Monolith-Utils

0 stars 0 forks source link

# Monolith Utils Setup

Download latest Monolith-Utils github repository.

Setup Command Line Environment:

Our tool is 100% command line, and VERY powerful!

Before continuing, it's best to have a command-line accessible text editor. If you don't already have one, consider using Visual Studio Code

Open Command Line

Open up a linux-based command line tool (Github has one or you can use WSL).

touch ~/.bashrc && code ~/.bashrc

In your .bashrc file, add the following lines to the bottom of your file:

alias deref="/c/…/Monolith-Utils/Deref/bin/debug/net8.0/deref.exe"

Save and close.

Back at your command line, type the following:

source ~/.bashrc

deref --help

Should see output.

Using Monolith Utils


There are 2 main libraries that are versioned in this repository:

Delinq CLI - Linq Conversion Tool

This app will parse a LINQ designer file and extract the necessary data that it needs to recreate the queries to a backing "Repository" approach. This will allow the queries to be run against a database without the need for the LINQ designer file.

Features

This is a command line tool that is intended to generate properly formatted C# code for any Repository with valid unit tests which ensure the methods are protected from future changes.

Parse DataContext File

Before we can generate code, we must first define what methods and parameters are used in the existing implementation.

$> delinq init "c:\temp\SomeDataContext.dbml"

This will create a SomeData.metadata.settings file which contains all the information needed to generate repository methods and unit tests.

Generate Repository Files

We defined a standard approach for calling the database.

Here is the line of code that will generate all of the above files:

$> delinq repo "c:\temp\SomeData.metadata.settings" -o "c:\temp\SomeData\RepoFiles"

If you only need to generate code for a specific method, you can define it using a flag:

$> delinq repo "c:\temp\SomeData.metadata.settings" -o "c:\temp\SomeData\RepoFiles" -m SomeSpecificMethodName

This is useful if you only have to generate code for a specific database call.

Generate Unit Test Files

We defined a standard approach for testing our repository methods.

Here is the line of code that will generate all of the above files:

$> delinq tests "c:\temp\SomeData.metadata.settings" -o "c:\temp\SomeData\TestFiles"

If you only need to generate test code for a specific repository method, you can define it using a flag:

$> delinq tests "c:\temp\SomeData.metadata.settings" -o "c:\temp\SomeData\TestFiles" -m SomeSpecificMethodName

This is useful if you only have to generate code for a specific database call.

Validate Repository Files

This is used to ensure that we have accounted for proper implementations of the repository methods.

$> delinq verify "c:\temp\SomeRepository.cs" SECRET:ConnectionStrings.InCode -o "c:\temp\Verification.json"

Note: This requires user secrets to be set up for the connection string.

dotnet user-secrets init
dotnet user-secrets set "ConnectionStrings:InCode" "YourConnectionString"

Generate Verification Report

Reads the json file generated from the verify results and generates a report of the findings.

NOTE: The results are output to "csv" format, but can be opened in Excel to filter and sort results easily.

$> delinq report "c:\temp\Verification.json"

Deref CLI - Monolith Solution and Project Analyzer

For now, we don't have a lot of information, as it's evolving very fast.

For now, simply use the following:

deref --help
deref branch --help
deref init --help
deref project --help
deref solution --help
deref wix --help

For More Information

Feel free to use the custom calls defined in the Delinq/Properties/launchSettings.json file to get started.