9 |
--------------------------------------------------------------------------------
/src/Genesis/Executors/IGeneralConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis.Executors
6 | {
7 | public interface IGeneralConfiguration
8 | {
9 | string OutputPath { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/MSSqlToReactEditor.genesis:
--------------------------------------------------------------------------------
1 | scan
2 | add mssql
3 | config mssql ConnectionString="Data Source=(localdb)\MSSQLLocalDB;Integrated Security=true;Database=GenesisTest;"
4 | add react-ec
5 | config react-ec FileExtension=".js"
6 | config react-ec OutputPath="C:\Temp\Output\ReactEditors"
7 | break
--------------------------------------------------------------------------------
/src/DemoSite/Models/ErrorViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DemoSite.Models
4 | {
5 | public class ErrorViewModel
6 | {
7 | public string RequestId { get; set; }
8 |
9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ReactEditorComponent/ReactEditorComponentConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 |
3 | namespace Genesis.Output.Poco
4 | {
5 | public class ReactEditorComponentConfig : GeneratorConfiguration
6 | {
7 | public string FileExtension { get; internal set; } = ".js";
8 | }
9 | }
--------------------------------------------------------------------------------
/src/Genesis.Cli.Extensions/Genesis.Cli.Extensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Genesis/Inputs/InputTaskResult.cs:
--------------------------------------------------------------------------------
1 | namespace Genesis.Input
2 | {
3 | public class InputGenesisExecutionResult : BlankGenesisExecutionResult, IGenesisExecutionResult
4 | {
5 | public override bool Success { get; set; } = true;
6 | public override string Message { get; set; } = "Success";
7 | }
8 | }
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.DotNetAssembly/AssemblyInputConfig.cs:
--------------------------------------------------------------------------------
1 | namespace Genesis.Input.DotNetAssembly
2 | {
3 | public class AssemblyInputConfig : InputConfiguration
4 | {
5 | public string AssemblyPath { get; set; } = "/Temp/TestAssembly.dll";
6 | public bool OnlyGenesisDecorations { get; set; } = true;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/Genesis/Executors/IGeneralExecutor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis.Executors
6 | {
7 | public interface IGeneralExecutor : IGenesisExecutor
8 | {
9 | IGeneralConfiguration Configuration { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetAutoMapper/AspNetAutoMapperGenerator.gen:
--------------------------------------------------------------------------------
1 | using ~DEPS_MODEL_NAMESPACE~;
2 | using ~DEPS_DTO_NAMESPACE~;
3 | using AutoMapper;
4 |
5 | namespace ~NAMESPACE~
6 | {
7 | public class Mapper : Profile
8 | {
9 | public void Initialize()
10 | {
11 | ~MAPPING_CODE~
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.Excel/ExcelSheetConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Input;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Input.Excel
7 | {
8 | public class ExcelSheetConfig : InputConfiguration
9 | {
10 | public string SourcePath { get; set; } = string.Empty;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Genesis/AttributeGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis
6 | {
7 | public class AttributeGraph : Graph
8 | {
9 | public AttributeGraph() : base(GraphTypes.Attribute) { }
10 | public override GraphTypes GraphType => GraphTypes.Attribute;
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProjectFiles/ProjectFilesGenerator.gen:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/Genesis/RelationshipGraph.cs:
--------------------------------------------------------------------------------
1 | namespace Genesis
2 | {
3 | public class RelationshipGraph
4 | {
5 | public string ForeignTable { get; set; } = "";
6 | public string ForeignColumn { get; set; } = "";
7 | public string PrimaryTable { get; set; } = "";
8 | public string PrimaryColumn { get; set; } = "";
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Genesis.Cli.Extensions/GenesisExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis.Cli.Extensions
6 | {
7 | //public static class GenesisExtensions
8 | //{
9 | // public static void Yes(this GenesisCommand command)
10 | // {
11 | // //just
12 | // }
13 | //}
14 | }
15 |
--------------------------------------------------------------------------------
/src/Genesis/Inputs/IInputExecutor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Threading.Tasks;
5 | using Genesis;
6 |
7 | namespace Genesis.Input
8 | {
9 | public interface IInputExecutor : IGenesisExecutor
10 | {
11 | IInputConfiguration Configuration { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProtobufService/ProtoServiceConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "namespace": "Genesis.Api.GrpcServices",
3 | "grpcNamespace": "Genesis.Api.Proto",
4 | "serviceSuffix": "GrpcService",
5 | "depsServiceNamespace": "Genesis.Services",
6 | "outputPath": "/Temp/Output/Proto-Services",
7 | "initNullable": true,
8 | "overwrite": "all",
9 | "preserve": "none"
10 | }
--------------------------------------------------------------------------------
/src/Genesis/GenesisGlobals.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | namespace Genesis
7 | {
8 | public static class GenesisGlobals
9 | {
10 | public static readonly string[] TrustedAssembliesPaths = ((string)AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES")).Split(Path.PathSeparator);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Executors/Genesis.Executors.GraphTools/GraphToolsConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System.Composition;
3 |
4 | namespace Genesis.Executors
5 | {
6 | [Export(nameof(IGeneralConfiguration), typeof(IGeneralConfiguration))]
7 | public class GraphToolsConfig : IGeneralConfiguration
8 | {
9 | public string OutputPath { get; set; } = @"Output\";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.MSSqlDB/SqlConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Input;
2 |
3 | namespace Genesis.Input.MSSqlDb
4 | {
5 | public class SqlConfig : InputConfiguration
6 | {
7 | public string ConnectionString { get; set; } = "Server=localhost;User=sa;Password=1234qwer";
8 | public string[] ExcludePrefixes { get; set; } = System.Array.Empty();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetAutoMapper/AspNetAutoMapperGenerator.deps:
--------------------------------------------------------------------------------
1 |
2 | ModelMap
3 | ModelMap.cs
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 | using AutoMapper;
8 |
9 | namespace ~NAMESPACE~
10 | {
11 | public partial class ModelMap : IProfile
12 | {
13 | public static ModelMap Current { get; } = new ModelMap();
14 | }
15 | }
--------------------------------------------------------------------------------
/.github/workflows/dotnetcore.yml:
--------------------------------------------------------------------------------
1 | name: .NET Core
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: windows-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v1
12 | - name: Setup .NET Core
13 | uses: actions/setup-dotnet@v1
14 | # with:
15 | # dotnet-version: 7.0.11
16 | - name: Build with dotnet
17 | run: dotnet build --configuration Release
18 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.Poco/PocoGenerator.gen:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ~NAMESPACE~
6 | {
7 | //[DebuggerDisplay("~OBJECT_NAME~~OUTPUT_SUFFIX~, Id={Id}, Genesis: Implement ~DEBUGGER_DISPLAY_PROPERTIES~")]
8 | public partial class ~OBJECT_NAME~~OUTPUT_SUFFIX~: ~OBJECT_BASECLASS~
9 | {
10 | ~PROPERTIES~
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.Poco/PocoConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "language": "C#",
3 | "namespace": "Genesis.Common",
4 | "outputPath": "/src/genesis-mvp/src/shared/Genesis.Common",
5 | "outputSuffix": "Dto",
6 | "depsPath": "/src/genesis-mvp/src/shared/Genesis.Common/",
7 | "depsNamespace": "Genesis.Common",
8 | "objectBaseClass": "Dto",
9 | "genericBaseClass": true,
10 | "overwrite": "all",
11 | "preserve": "none"
12 | }
--------------------------------------------------------------------------------
/src/Genesis/EventGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis
6 | {
7 | public class EventGraph : Graph
8 | {
9 | public string Name { get; set; } = "SomethingHappened";
10 | public string DelegateFormattedName { get; set; } = "EventHandler";
11 | public EventGraph() : base(GraphTypes.Event)
12 | {
13 |
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Genesis/GenesisObjectAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis
6 | {
7 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
8 | public sealed class GenesisObjectAttribute : Attribute
9 | {
10 | public GenesisObjectAttribute()
11 | {
12 |
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/LocalSQLtoMVPsite.genesis:
--------------------------------------------------------------------------------
1 | scan
2 | add mssql
3 | config mssql
4 | add poco
5 | config poco
6 | add aspnet-repo-cached
7 | config aspnet-repo-cached
8 | add aspnet-repo
9 | config aspnet-repo
10 | add ef-model
11 | config ef-model
12 | add aspnet-svc
13 | config aspnet-svc
14 | add aspnet-map
15 | config aspnet-map
16 | add aspnet-mvc-con
17 | config aspnet-mvc-con
18 | add project-files
19 | config project-files
20 | status
21 | exec chain
22 | break
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.EFCoreModel/EFCoreModelGenerator.gen:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using ~DEPS_NAMESPACE~;
5 |
6 | namespace ~NAMESPACE~
7 | {
8 | public partial class ~OBJECT_NAME~~OUTPUT_SUFFIX~: ~BASE_CLASS~
9 | {
10 | public ~OBJECT_NAME~~OUTPUT_SUFFIX~()
11 | {
12 | ~CONSTRUCTION~
13 | }
14 |
15 | ~PROPERTIES~
16 |
17 | ~RELATIONSHIPS~
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Genesis/Outputs/OutputTaskResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis.Output
6 | {
7 | public class OutputGenesisExecutionResult : BlankGenesisExecutionResult, IGenesisExecutionResult
8 | {
9 | public override bool Success { get; set; } = true;
10 | public override string Message { get; set; } = "Success"; //cli warns for no reason apparently
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.EFCoreModel/EFCoreModelConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "language": "C#",
3 | "namespace": "Genesis.Data",
4 | "outputPath": "/src/genesis-mvp/src/server/Genesis.Data/Entities",
5 | "outputSuffix": "",
6 | "objectBaseClass": "Entity",
7 | "genericBaseClass": true,
8 | "depsPath": "/src/genesis-mvp/src/server/Genesis.Data/.Internal",
9 | "depsNamespace": "Genesis.Data",
10 | "overwrite": "all",
11 | "preserve": "none"
12 | }
--------------------------------------------------------------------------------
/src/Genesis.Cli/LocalSQLtoMVPsite.genesis:
--------------------------------------------------------------------------------
1 | scan
2 | add mssql
3 | config mssql
4 | add poco
5 | config poco
6 | add aspnet-repo-cached
7 | config aspnet-repo-cached
8 | add aspnet-repo
9 | config aspnet-repo
10 | add ef-model
11 | config ef-model
12 | add aspnet-svc
13 | config aspnet-svc
14 | add aspnet-map
15 | config aspnet-map
16 | add aspnet-mvc-con
17 | config aspnet-mvc-con
18 | add project-files
19 | config project-files
20 | status
21 | exec chain
22 | break
--------------------------------------------------------------------------------
/src/Genesis/BlankTaskResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis
6 | {
7 | public class BlankGenesisExecutionResult : IGenesisExecutionResult
8 | {
9 | public BlankGenesisExecutionResult()
10 | {
11 |
12 | }
13 |
14 | public virtual bool Success { get; set; } = true;
15 | public virtual string Message { get; set; } = string.Empty;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Genesis/Outputs/Templates/StringTemplate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis.Output.Templates
6 | {
7 | public class StringTemplate : IGeneratorTemplate
8 | {
9 | private readonly string content = string.Empty;
10 | public string Raw => content;
11 |
12 | public StringTemplate(string contents)
13 | {
14 | content = contents;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Genesis/Graph.cs:
--------------------------------------------------------------------------------
1 | namespace Genesis
2 | {
3 | public enum GraphTypes
4 | {
5 | Object,
6 | Property,
7 | Method,
8 | Event,
9 | Attribute,
10 | Parameter,
11 | }
12 | public abstract class Graph : IGraph
13 | {
14 | protected Graph(GraphTypes eventGraphType)
15 | => GraphType = eventGraphType;
16 |
17 | public virtual GraphTypes GraphType { get; private set; } = GraphTypes.Object;
18 | }
19 | }
--------------------------------------------------------------------------------
/tools/TestInputAssembly/TestInputAssembly.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | 9.0
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.JavascriptObject/JavascriptObjectGenerator.gen:
--------------------------------------------------------------------------------
1 | export default class ~OBJECT_NAME~~OUTPUT_SUFFIX~ {
2 | constructor(options = {}) {
3 | ~PROPERTIES~
4 | }
5 |
6 | parseJson(schema) {
7 | try {
8 | return JSON.parse(schema);
9 | } catch (err) {
10 | console.log('Could not parse ~OBJECT_NAME~~OUTPUT_SUFFIX~ into a DTO.')
11 | return null;
12 | }
13 | }
14 |
15 | stringify() {
16 | return JSON.stringify(this);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.Excel/Genesis.Input.Excel.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.SwaggerUrl/SwagConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Input;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Input.SwaggerUrl
7 | {
8 | public class SwagConfig : InputConfiguration
9 | {
10 | public string Address { get; set; } = string.Empty;
11 | public string OutputNamespace { get; set; } = "Genesis.Rest.Clients";
12 | public string LanguageVersion { get; set; } = "CSharp8";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.JavascriptObject/JavascriptObjectConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.Poco
7 | {
8 | public class JavascriptObjectConfig : GeneratorConfiguration
9 | {
10 | public string Language { get; set; } = "Javascript";
11 | public string Overwrite { get; set; } = "all";
12 | public string Preserve { get; set; } = "none";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Genesis/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 |
6 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification = "Why not?", Scope = "member", Target = "~P:Genesis.ObjectGraph.GenericArgumentTypes")]
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextRepositories/RepoConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "language": "C#",
3 | "namespace": "Genesis.Data",
4 | "outputPath": "/src/genesis-mvp/src/server/Genesis.Data",
5 | "outputSuffix": "Repository",
6 | "depsPath": "/src/genesis-mvp/src/server/Genesis.Data/.Internal",
7 | "depsNamespace": "Genesis.Data",
8 | "depsModelNamespace": "Genesis.Data",
9 | "modelBaseClass": "Entity",
10 | "genericBaseClass": true,
11 | "overwrite": "all",
12 | "preserve": "none"
13 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextRepositories/RepositoryGenerator.gen:
--------------------------------------------------------------------------------
1 | using ~DEPS_MODEL_NAMESPACE~;
2 |
3 | namespace ~NAMESPACE~
4 | {
5 | public interface I~OBJECT_NAME~~OUTPUT_SUFFIX~ : I~OUTPUT_SUFFIX~<~OBJECT_NAME~, ~KEY_DATATYPE~> { }
6 |
7 | public sealed class ~OBJECT_NAME~~OUTPUT_SUFFIX~ : ~OUTPUT_SUFFIX~<~OBJECT_NAME~, ~KEY_DATATYPE~>, I~OBJECT_NAME~~OUTPUT_SUFFIX~
8 | {
9 | public ~OBJECT_NAME~~OUTPUT_SUFFIX~(~DEPS_DBCONTEXT~ context) : base(context) { }
10 | }
11 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProtobufEntity/ProtoConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.Protos
7 | {
8 | public class ProtoConfig : GeneratorConfiguration
9 | {
10 | public int Version { get; set; } = 3;
11 | public string Overwrite { get; set; } = "all";
12 | public string Preserve { get; set; } = "none";
13 | public string GrpcNamespace { get; set; } = "Genesis.Api.Proto";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.EFCoreModel/EFCoreModelGenerator.deps:
--------------------------------------------------------------------------------
1 |
2 | ~OBJECT_BASECLASS~
3 | \~OBJECT_BASECLASS~.cs
4 | using System.ComponentModel.DataAnnotations;
5 |
6 | namespace ~NAMESPACE~
7 | {
8 | public interface I~OBJECT_BASECLASS~
9 | where TKey : struct
10 | {
11 | TKey Id { get; set; }
12 | }
13 |
14 | public class ~OBJECT_BASECLASS~ : I~OBJECT_BASECLASS~
15 | where TKey : struct
16 | {
17 | [Key]
18 | public TKey Id { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProjectFiles/ProjectFilesConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.Poco
7 | {
8 | public class ProjectFilesConfig : GeneratorConfiguration
9 | {
10 | public Dictionary Projects { get; set; } = new();
11 | public string Language { get; set; } = "C#";
12 | public string Overwrite { get; set; } = "all";
13 | public string Preserve { get; set; } = "none";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextCachedRepositories/CachedRepoConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "language": "C#",
3 | "namespace": "Genesis.Data",
4 | "outputPath": "/src/genesis-mvp/src/server/Genesis.Data",
5 | "outputSuffix": "CachedRepository",
6 | "depsPath": "/src/genesis-mvp/src/server/Genesis.Data/.Internal",
7 | "depsNamespace": "Genesis.Data",
8 | "depsModelNamespace": "Genesis.Data",
9 | "depsRepoNamespace": "Genesis.Data",
10 | "modelBaseClass": "Entity",
11 | "genericBaseClass": true,
12 | "overwrite": "all",
13 | "preserve": "none"
14 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProjectFiles/ProjectFilesConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "language": "C#",
3 | "overwrite": "false",
4 | "preserve": "none",
5 | "projects": {
6 | "Genesis.Framework.csproj": "/src/genesis-mvp/src/server/Genesis.Framework",
7 | "Genesis.Common.csproj": "/src/genesis-mvp/src/shared/Genesis.Common",
8 | "Genesis.Data.csproj": "/src/genesis-mvp/src/server/Genesis.Data",
9 | "Genesis.Services.csproj": "/src/genesis-mvp/src/server/Genesis.Services",
10 | "Genesis.Server.csproj": "/src/genesis-mvp/src/server/Genesis.Server"
11 | }
12 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.Poco/PocoConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.Poco
7 | {
8 | public class PocoConfig : GeneratorConfiguration
9 | {
10 | public string ObjectBaseClass { get; set; } = "Model";
11 | public bool GenericBaseClass { get; set; } = false;
12 | public string Language { get; set; } = "C#";
13 | public string Overwrite { get; set; } = "all";
14 | public string Preserve { get; set; } = "none";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Genesis.Cli.Extensions/IGenesisCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 |
5 | namespace Genesis.Cli.Extensions
6 | {
7 | public interface IGenesisCommand
8 | {
9 | string Name { get; }
10 | string HelpTemplate { get; }
11 | string Description { get; }
12 | string Usage { get; }
13 |
14 | Task InitializeAsync(string[] args);
15 |
16 | Task ProcessHelpCommand(string[] args);
17 |
18 | Task Execute(GenesisContext genesis, string[] args);
19 | }
20 | }
--------------------------------------------------------------------------------
/src/DemoSite/DemoSite.Web.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetAutoMapper/AspNetAutoMapperConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "language": "C#",
3 | "namespace": "Genesis.Services",
4 | "outputPath": "/src/genesis-mvp/src/server/Genesis.Services/Mapping",
5 | "depsPath": "/src/genesis-mvp/src/server/Genesis.Services/.Internal",
6 | "depsDtoNamespace": "Genesis.Common",
7 | "depsModelNamespace": "Genesis.Data",
8 | "depsMapperNamespace": "Genesis.Services",
9 | "objectBaseClass": "",
10 | "dtoBaseClass": "Dto",
11 | "genericBaseClass": false,
12 | "mapperSuffix": "Mapper",
13 | "overwrite": "all",
14 | "preserve": "none"
15 | }
--------------------------------------------------------------------------------
/src/Genesis/Exceptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis
6 | {
7 | public class InvalidGenesisScriptException : Exception
8 | {
9 | public InvalidGenesisScriptException(string scriptPath) : base($"Invalid script path '{scriptPath}'") { }
10 | }
11 |
12 | public class ExecutionAggregateException : AggregateException
13 | {
14 | public ExecutionAggregateException() : base("One or more exceptions have occured while executing the GenesisContext. See inner exceptions for details") { }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.XamarinViewModel/XvmGenerator.gen:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using ~NAMESPACE~.Models;
4 |
5 | namespace ~NAMESPACE~.ViewModels
6 | {
7 | public class ~OBJECT_NAME~DetailViewModel : BaseViewModel
8 | {
9 | private ~OBJECT_NAME~? _instance = null;
10 |
11 | public ~OBJECT_NAME~ Instance { get => _instance; set => SetProperty(value); }
12 |
13 | public ItemDetailViewModel(~OBJECT_NAME~ instance = null)
14 | {
15 | //TODO: This template is cringy
16 | _instance = instance ?? new ~OBJECT_NAME~();
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.EFCoreModel/EFCoreModelConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.EFCoreModel
7 | {
8 | public class EFCoreModelConfig : GeneratorConfiguration
9 | {
10 | public string ObjectBaseClass { get; set; } = "Model";
11 | public string Language { get; set; } = "C#";
12 | public string Overwrite { get; set; } = "all";
13 | public string Preserve { get; set; } = "none";
14 | public bool GenericBaseClass { get; set; } = true;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.DotNetAssembly/Genesis.Input.DotNetAssembly.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Always
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetMvcController/MvcControllerConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "language": "C#",
3 | "namespace": "Genesis.Api.Controllers",
4 | "outputPath": "/src/genesis-mvp/src/server/Genesis.Server/Controllers",
5 | "overwrite": true,
6 | "serviceSuffix": "Service",
7 | "depsServiceNamespace": "Genesis.Services",
8 | "depsDtoNamespace": "Genesis.Common",
9 | "depsModelNamespace": "Genesis.Data",
10 | "depsMappingNamespace": "Genesis.Services",
11 | "depsNamespace": "Genesis.Framework",
12 | "preserve": "none",
13 | "injections": [
14 | "IAuthService",
15 | "IAccountService"
16 | ]
17 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.XamarinView/Genesis.Output.XamarinView.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Executors/Genesis.Executors.GraphTools/Genesis.Executors.GraphTools.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProtobufEntity/Genesis.Output.ProtobufEntity.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.XamarinViewModel/Genesis.Output.XamarinViewModel.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProtobufService/Genesis.Output.ProtobufService.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetMvcController/Genesis.Output.AspNetMvcController.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Genesis/Dbug.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Text;
5 |
6 | namespace Genesis
7 | {
8 | public static class Dbug
9 | {
10 | ///
11 | /// Writes a line to Debug.WriteLine
12 | ///
13 | /// 'this'
14 | /// the message you want written
15 | public static void Dump(object sender, string message = "")
16 | {
17 | Debug.WriteLine($@"{sender.GetType().Name}.{new StackTrace().GetFrame(1).GetMethod().Name}|{message}");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/DemoSite/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) .NET Foundation. All rights reserved.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 | these files except in compliance with the License. You may obtain a copy of the
5 | License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software distributed
10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 | specific language governing permissions and limitations under the License.
13 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/README.md:
--------------------------------------------------------------------------------
1 | # Commands
2 | Commands are what basically trigger certain things to happen through a Session. There are a few default commands that are pretty integral to this whole thing working:
3 |
4 | |Command|Description|
5 | | ------------- |----- |
6 | | ? | Lists all the commands that have been discovered |
7 | | scan | Locates the executors that are available |
8 | | status | Display some handy info about the state |
9 | | config | View or change executor configurations |
10 | | exec | Execute a chain of executors or one by one |
11 | | add | Add an executor that's been scanned to the chain |
12 | | clear | Clears the execution chain for reuse if need be |
--------------------------------------------------------------------------------
/src/Genesis/IGenesisExecutor.cs:
--------------------------------------------------------------------------------
1 | using Genesis;
2 | using System.Threading.Tasks;
3 |
4 | namespace Genesis
5 | {
6 | public interface IGenesisExecutor where TGenesisExecutionResult : IGenesisExecutionResult
7 | {
8 | string CommandText { get; }
9 | string Description { get; }
10 | string FriendlyName { get; }
11 |
12 | bool Initialized { get; }
13 | Task Initialize();
14 | Task DisplayConfiguration();
15 | Task EditConfig(string propertyName, TPropertyType value);
16 | Task Execute(GenesisContext genesis, string[] args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ReactEditorComponent/Genesis.Output.ReactEditorComponent.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Genesis/GenesisDefaults.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | namespace Genesis
7 | {
8 | public class GenesisDefaults
9 | {
10 | public static readonly string OutputPath = Path.Combine(Environment.CurrentDirectory, "Output");
11 | public static readonly string Namespace = "Default.Namespace";
12 | public static readonly string LibraryExtension = ".dll";
13 | public static readonly string TemplateExtension = ".template";
14 | public static readonly string UnknownSourceType = "UNKNOWN";
15 | public static readonly string DependenciesExtension = ".deps";
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Genesis/Inputs/InputConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System.Composition;
2 |
3 | namespace Genesis.Input
4 | {
5 | ///
6 | /// Primary configuration class for individual Current
7 | ///
8 | [Export(nameof(IInputConfiguration), typeof(IInputConfiguration))]
9 | public class InputConfiguration : IInputConfiguration
10 | {
11 | public InputConfiguration()
12 | {
13 | //inherit this and declare a public property called .Config; on your custom Executor.
14 | //Genesis will activate an instance for you during discovery and assign it to your executor if the stars align. (if it exists, and is parsable)
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextCachedRepositories/CachedRepoConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.CachedRepo
7 | {
8 | public class CachedRepoConfig : GeneratorConfiguration
9 | {
10 | public string ObjectBaseClass { get; set; } = "IRepository";
11 | public string ModelBaseClass { get; set; } = "Model";
12 | public bool GenericBaseClass { get; set; } = true;
13 | public string DepsModelNamespace { get; set; } = "Genesis.Data.Models";
14 | public string DepsRepoNamespace { get; set; } = "Genesis.Data.Repositories";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/UpdateCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace Genesis.Cli.Commands
9 | {
10 | public class UpdateCommand : GenesisCommand
11 | {
12 | public override string Name { get => "update"; }
13 | public override string Description => "Eventually download latest and restart";
14 |
15 | public override async Task Execute(GenesisContext genesis, string[] args)
16 | {
17 | return await Task.FromResult(new BlankGenesisExecutionResult());
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.MySqlDb/MySqlConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Genesis.Input.MySqlDb
4 | {
5 | public class MySqlConfig : InputConfiguration
6 | {
7 | public string Server { get; set; } = "";
8 | public string Database {get;set;} = "";
9 | public string UserId { get; set; } = "";
10 | public string Password { get; set; } = "";
11 | public bool ConvertZeroDateTime { get; set; } = true;
12 | public string ToConnectionString()
13 | => $"Server={Server};Database={Database};UID={UserId};PWD={Password};ConvertZeroDateTime={ConvertZeroDateTime};";
14 |
15 | public string[] ExcludePrefixes { get; set; } = Array.Empty();
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextRepositories/RepoConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.CachedRepo
7 | {
8 | public class RepoConfig : GeneratorConfiguration
9 | {
10 | public string ObjectBaseClass { get; set; } = "IRepository";
11 | public string ModelBaseClass { get; set; } = "Model";
12 | public bool GenericBaseClass { get; set; } = true;
13 | public string DepsModelNamespace { get; set; } = "Genesis.Data.Models";
14 | public string DepsRepoNamespace { get; set; } = "Genesis.Data.Repositories";
15 | public string DepsDbContext { get; set; } = "AppDbContext";
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetService/AspNetServiceConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "language": "C#",
3 | "namespace": "Genesis.Services",
4 | "outputPath": "/src/genesis-mvp/src/server/Genesis.Services",
5 | "depsPath": "/src/genesis-mvp/src/server/Genesis.Services/.Internal",
6 | "depsDtoNamespace": "Genesis.Common",
7 | "depsModelNamespace": "Genesis.Data",
8 | "depsMapperNamespace": "Genesis.Services",
9 | "depsNamespace": "Genesis.Services",
10 | "objectBaseClass": "Entity",
11 | "dtoBaseClass": "Dto",
12 | "genericBaseClass": true,
13 | "outputSuffix": "Service",
14 | "mapperSuffix": "Mapper",
15 | "repoSuffix": "Repository",
16 | "cachedRepoSuffix": "CachedRepository",
17 | "overwrite": "all",
18 | "preserve": "none"
19 | }
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/DefaultCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using Genesis.Output;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 |
9 | namespace Genesis.Cli.Commands
10 | {
11 | public class DefaultCommand : GenesisCommand
12 | {
13 | public override string Name => "";
14 | public override string Description => "";
15 |
16 | public override async Task Execute(GenesisContext genesis, string[] args)
17 | {
18 | return await Task.FromResult(new OutputGenesisExecutionResult() { Success = true, Message = "Bad command or file name" }); //heh
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Genesis/Genesis.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.JavascriptObject/Genesis.Output.JavascriptObject.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Always
15 |
16 |
17 | Always
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetAutoMapper/Genesis.Output.AspNetAutoMapper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Always
15 |
16 |
17 | Always
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Genesis/Outputs/IOutputExecutor.cs:
--------------------------------------------------------------------------------
1 | using Genesis;
2 | using Genesis.Output;
3 | using System;
4 | using System.Collections.Concurrent;
5 | using System.Collections.Generic;
6 | using System.Threading.Tasks;
7 |
8 | namespace Genesis.Output
9 | {
10 | public interface IOutputExecutor : IGenesisExecutor
11 | {
12 | Task AttachDependencies(IList deps);
13 | Task DepositDependencies(string outputRoot);
14 |
15 | IDictionary> Actions { get; }
16 |
17 | IGeneratorTemplate Template { get; set; }
18 |
19 | IOutputConfiguration Configuration { get; set; }
20 | IList Dependencies { get; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Genesis/Outputs/Templates/TemplateLoader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.Templates
7 | {
8 | public static class TemplateLoader
9 | {
10 | public static IGeneratorTemplate LoadTemplateFor(IOutputExecutor generator)
11 | {
12 | var templateFilePath = Path.Combine(Environment.CurrentDirectory, generator.GetType().Name + ".gen"); //TODO: hard coded path
13 |
14 | if (!File.Exists(templateFilePath))
15 | throw new FileNotFoundException(templateFilePath);
16 |
17 | var contents = File.ReadAllText(templateFilePath);
18 | return new StringTemplate(contents);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/WaitCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Genesis.Cli.Commands
8 | {
9 | class WaitCommand : GenesisCommand
10 | {
11 | public override string Name { get => "wait"; }
12 |
13 | public override string Description => "Pause (a script) until user input";
14 |
15 | public override async Task Execute(GenesisContext genesis, string[] args)
16 | {
17 | Text.DarkYellowLine("Paused... press the any key");
18 | Console.ReadKey();
19 |
20 | return await Task.FromResult(new BlankGenesisExecutionResult());
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextRepositories/Genesis.Output.AspNetDbContextRepositories.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 | Always
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Genesis .Net
2 | An exploritory orchestration-based code generation tool. Data from pretty much any source that .Net is able to consume can be used to generate a variety of boilerplate code files or execute arbitrary code.
3 |
4 | # First run
5 | * The first thing that needs to happen is for the cli to scan for executors and make them available to Genesis. Do this by simply typing `scan`. (this is scriptable)
6 | * You should see what *[Executors](https://github.com/genesisdotnet/genesis/blob/master/src/Genesis/IGenesisExecutor.cs)* were found in the output.
7 | * They're addressable by their green text.
8 |
9 | * Forgive the short docs... but
10 | * exec 'something in green text'
11 |
12 | 
13 |
--------------------------------------------------------------------------------
/src/DemoSite/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.Extensions.Logging;
9 |
10 | namespace DemoSite
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | CreateHostBuilder(args).Build().Run();
17 | }
18 |
19 | public static IHostBuilder CreateHostBuilder(string[] args) =>
20 | Host.CreateDefaultBuilder(args)
21 | .ConfigureWebHostDefaults(webBuilder =>
22 | {
23 | webBuilder.UseStartup();
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextCachedRepositories/Genesis.Output.AspNetDbContextCachedRepositories.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Always
14 |
15 |
16 | Always
17 |
18 |
19 | Always
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProtobufService/ProtoServiceConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.Protos
7 | {
8 | public class ProtoServiceConfig : GeneratorConfiguration
9 | {
10 | public int Version { get; set; } = 3;
11 | public string GrpcNamespace { get; set; } = "Genesis.Api.Proto";
12 | public string DepsServiceNamespace { get; set; } = "Genesis.Services";
13 | public string DepsDtoNamespace { get; set; } = "Genesis.Common";
14 | public string ServiceSuffix { get; set; } = "GrpcService";
15 | public bool InitNullable { get; set; } = true;
16 | public string Overwrite { get; set; } = "all";
17 | public string Preserve { get; set; } = "none";
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProtobufEntity/ProtoGenerator.gen:
--------------------------------------------------------------------------------
1 | // ~OBJECT_NAME~.proto
2 | syntax = "proto~VERSION~";
3 |
4 | option csharp_namespace = "~GRPC_NAMESPACE~";
5 |
6 | package ~OBJECT_NAME~Package;
7 |
8 | service ~OBJECT_NAME~ProtoService {
9 | rpc Add~OBJECT_NAME~ (~OBJECT_NAME~) returns (SuccessOrFailResult);
10 | rpc Get~OBJECT_NAME~ (~OBJECT_NAME~Key) returns (~OBJECT_NAME~);
11 | rpc Put~OBJECT_NAME~ (~OBJECT_NAME~) returns (SuccessOrFailResult);
12 | rpc Delete~OBJECT_NAME~ (~OBJECT_NAME~Key) returns (SuccessOrFailResult);
13 | ~METHODS~
14 | }
15 |
16 | message ~OBJECT_NAME~Key {
17 | ~KEY_DATATYPE~ Id = 1;
18 | }
19 |
20 | message SuccessOrFailResult { // make global somehow?
21 | bool Result = 1;
22 | string Message = 2;
23 | string Exception = 3;
24 | }
25 |
26 | message ~OBJECT_NAME~ {
27 | ~PROPERTIES~
28 | }
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using DemoSite.Models;
8 |
9 | namespace DemoSite.Controllers
10 | {
11 | public class HomeController : Controller
12 | {
13 | public IActionResult Index()
14 | {
15 | return View();
16 | }
17 |
18 | public IActionResult Privacy()
19 | {
20 | return View();
21 | }
22 |
23 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
24 | public IActionResult Error()
25 | {
26 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextCachedRepositories/CachedRepositoryGenerator.gen:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Caching.Memory;
2 |
3 | namespace ~NAMESPACE~
4 | {
5 | public interface I~OBJECT_NAME~~OUTPUT_SUFFIX~ : IReadOnlyRepository<~OBJECT_NAME~, ~KEY_DATATYPE~> { }
6 |
7 | public partial class ~OBJECT_NAME~~OUTPUT_SUFFIX~ : CachedRepository<~OBJECT_NAME~, ~KEY_DATATYPE~>, I~OBJECT_NAME~~OUTPUT_SUFFIX~
8 | {
9 | //public ~OBJECT_NAME~~OUTPUT_SUFFIX~(I~OBJECT_NAME~Repository repository, IDistributedCache cacheObject)
10 | public ~OBJECT_NAME~~OUTPUT_SUFFIX~(I~OBJECT_NAME~Repository repository, IMemoryCache cacheObject)
11 | :base(repository, cacheObject)
12 | {
13 | // _repo is the Repository, _cache is the IMemoryCache or IDistributedCache interface on the base
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Genesis/Outputs/GeneratorConfiguration.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Configuration;
2 | using System.Composition;
3 |
4 | namespace Genesis.Output
5 | {
6 | ///
7 | /// Primary configuration class for individual Current
8 | ///
9 | [Export(nameof(IOutputConfiguration), typeof(IOutputConfiguration))]
10 | public class GeneratorConfiguration : IOutputConfiguration
11 | {
12 | public GeneratorConfiguration()
13 | {
14 |
15 | }
16 | public string Namespace { get; set; } = GenesisDefaults.Namespace;
17 | public string OutputPath { get; set; } = GenesisDefaults.OutputPath;
18 | public string OutputSuffix { get; set; } = string.Empty;
19 | public string DepsNamespace { get; set; } = "Genesis.Framework";
20 | public string DepsPath { get; set; } = "/Temp/Output/";
21 | }
22 | }
--------------------------------------------------------------------------------
/src/Executors/Output/README.md:
--------------------------------------------------------------------------------
1 | ## Current Inputs
2 |
3 | * Microsoft SQL Database (easiest)
4 | Swagger API URL (mostly works)
5 | .Net (Core for now) Assembly via reflection
6 |
7 | ## Current Outputs
8 |
9 | These are the currently supported outputs:
10 |
11 | * AspNetCore Mvc Controller classes with Crud Operations
12 | * AspNetCore Service classes that Automap between Repo Model and Api Dto
13 | * AspNetCore EFcore entity repository
14 | * AspNetCore Cached EFCore entity repository
15 | * Basic React.js editor component w/inputs for properties
16 | * Basic Javascript Dto objects
17 | * Grpc .proto file generation with Crud operations.
18 | * Grpc AspNetCore Service implementation of ^ generated code
19 | * Plain C# objects w/optional Suffix to object Names
20 | * Xamarin.Forms View .xaml files with inputs for properties
21 | * Xamarin.Forms ViewModel class w/INotifyPropertyChanged
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.MSSqlDB/Genesis.Input.MSSqlDb.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Always
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetService/Genesis.Output.AspNetService.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Always
15 |
16 |
17 | Always
18 |
19 |
20 | Always
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/ExitCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.Text;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 |
9 | namespace Genesis.Cli.Commands
10 | {
11 | public class ExitCommand : GenesisCommand
12 | {
13 | public override string Name { get => "exit"; }
14 |
15 | public override string Description => "Exit the app";
16 |
17 | public override async Task Execute(GenesisContext genesis, string[] args)
18 | {
19 | Debug.WriteLine($@"{GetType().Name}.{nameof(Execute)}");
20 | Console.WriteLine("Exiting");
21 |
22 | Environment.Exit(0); //untz
23 |
24 | return await Task.FromResult(new BlankGenesisExecutionResult());
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Genesis/PropertyGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Genesis
4 | {
5 | public class PropertyGraph : Graph, IKeyable //TODO: make observable?
6 | {
7 | public PropertyGraph() : base(GraphTypes.Property) { }
8 | public override GraphTypes GraphType => GraphTypes.Property;
9 |
10 | public string Name { get; set; }
11 | public string SourceType { get; set; } = "object";
12 | public string TypeGuess { get; set; } = "object"; //what is presumed to be needed in a generator
13 | public bool IsNullable { get; set; } = true;
14 | public bool IsKeyProperty { get; set; } = false;
15 | public MethodVisibilities GetterVisibility { get; set; } = MethodVisibilities.Public;
16 | public MethodVisibilities SetterVisibility { get; set; } = MethodVisibilities.Public;
17 | public short MaxLength { get; set; } = 250;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.Poco/Genesis.Output.Poco.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Always
15 |
16 |
17 | Always
18 |
19 |
20 | Always
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.MySqlDb/Genesis.Input.MySqlDb.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | Always
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/BreakCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Genesis.Cli.Commands
8 | {
9 | class BreakCommand : GenesisCommand
10 | {
11 | public override string Name { get => "break"; }
12 |
13 | public override string Description => "Stop a script";
14 |
15 | public override async Task Execute(GenesisContext genesis, string[] args)
16 | {
17 | //NOTE: This apparently can't affect anything on the Program class itself. (without some voodoo)
18 | //So, just dump some text and check for this command in Program.
19 | Text.DarkYellowLine("Breaking...");
20 | Text.Line();
21 |
22 | return await Task.FromResult(new BlankGenesisExecutionResult { Success = true });
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.EFCoreModel/Genesis.Output.EFCoreModel.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Always
15 |
16 |
17 | Always
18 |
19 |
20 | Always
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/DemoSite/Views/Shared/Error.cshtml:
--------------------------------------------------------------------------------
1 | @model ErrorViewModel
2 | @{
3 | ViewData["Title"] = "Error";
4 | }
5 |
6 |
Error.
7 |
An error occurred while processing your request.
8 |
9 | @if (Model.ShowRequestId)
10 | {
11 |
12 | Request ID:@Model.RequestId
13 |
14 | }
15 |
16 |
Development Mode
17 |
18 | Swapping to Development environment will display more detailed information about the error that occurred.
19 |
20 |
21 | The Development environment shouldn't be enabled for deployed applications.
22 | It can result in displaying sensitive information from exceptions to end users.
23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
24 | and restarting the app.
25 |
26 |
--------------------------------------------------------------------------------
/src/Genesis/ParameterGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Xml.Serialization;
5 |
6 | namespace Genesis
7 | {
8 | public class ParameterGraph : Graph
9 | {
10 | public ParameterGraph() : base(GraphTypes.Parameter) { }
11 |
12 | [XmlIgnore]
13 | public Type DataType { get; set; }
14 | [XmlIgnore]
15 | public object Value { get; set; }
16 |
17 | public string Name { get; set; }
18 | public bool IsOut { get; set; }
19 | public bool IsOptional { get; set; }
20 | public int Position { get; set; }
21 | public string DataTypeFormattedName { get; set; }
22 | public bool IsIn { get; set; }
23 | public bool IsGeneric { get; set; }
24 | public bool IsGenericMethodParameter { get; set; }
25 | public string DisplayName { get; set; }
26 | public string[] GenericArgumentFormattedTypeNames { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Genesis/Outputs/GenesisDependency.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis.Output
6 | {
7 | public class DependencyEventArgs : EventArgs
8 | {
9 | private GenesisDependency _dependency;
10 |
11 | public DependencyEventArgs(GenesisDependency dependency)
12 | {
13 | _dependency = dependency;
14 | }
15 |
16 | public GenesisDependency Dependency {get=>_dependency;set=> _dependency = value;}
17 | }
18 |
19 | public class GenesisDependency : IOutputDependency
20 | {
21 | public GenesisDependency(string pathFragment, string objectName, string contents)
22 | {
23 | PathFragment = pathFragment;
24 | Contents = contents;
25 | ObjectName = objectName;
26 | }
27 |
28 | public string PathFragment { get; set; }
29 | public string Contents { get; set; }
30 | public string ObjectName { get; set; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Genesis/GenesisAssemblyLoadContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using System.Runtime.Loader;
5 | using System.Runtime.CompilerServices;
6 | using System.Text;
7 |
8 | namespace Genesis
9 | {
10 | ///
11 | /// Load and Unload assemblies
12 | ///
13 | public class GenesisAssemblyLoadContext : AssemblyLoadContext
14 | {
15 | private readonly AssemblyDependencyResolver _resolver;
16 |
17 | public GenesisAssemblyLoadContext(string path = "./") : base(true) // true means it's collectible, i.e. able to unload assemblies
18 | {
19 | _resolver = new AssemblyDependencyResolver(path);
20 | }
21 |
22 | protected override Assembly Load(AssemblyName name)
23 | {
24 | var assemblyPath = _resolver.ResolveAssemblyToPath(name);
25 | return assemblyPath != null
26 | ? LoadFromAssemblyPath(assemblyPath)
27 | : null;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.Excel/ExcelSheetObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading.Tasks;
4 |
5 | namespace Genesis.Input.Excel
6 | {
7 | public class ExcelSheetInput : InputExecutor
8 | {
9 | public override string CommandText => "xl";
10 | public override string FriendlyName => "An .xlsx Sheet";
11 | public override string Description => "A Workbook or data from within an .xlsx (MS Excel) file";
12 |
13 | public ExcelSheetConfig Config { get; set; }
14 |
15 | protected override void OnInitialized(/*, string[] args */) //TODO: Pass args to the init
16 | {
17 | Config = (ExcelSheetConfig)Configuration; //TODO: configuration is wonky
18 | }
19 |
20 | public override async Task Execute(GenesisContext genesis, string[] args)
21 | {
22 | //TODO: Use some open source library to read from an .xls(x) file
23 |
24 | return await base.Execute(genesis, args);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetMvcController/MvcControllerConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | #nullable enable
5 |
6 | namespace Genesis.Output.AspNetMvcController
7 | {
8 | public class MvcControllerConfig : GeneratorConfiguration
9 | {
10 | public string DtoSuffix { get; set; } = "Dto";
11 | public string Language { get; set; } = "C#";
12 | public bool Overwrite { get; set; } = true;
13 | public string Preserve { get; set; } = string.Empty;
14 | public string DepsServiceNamespace { get; set; } = "Genesis.Services";
15 | public string DepsModelNamespace { get; set; } = "Genesis.Data.Models";
16 | public string DepsMappingNamespace { get; set; } = "Genesis.Services.Mapping";
17 | public string ServiceSuffix { get; set; } = "Service";
18 | public string DepsDtoNamespace { get; set; } = "Genesis.Common";
19 | public bool InitNullable { get; set; } = true;
20 | [Obsolete("Too common to one-off.")] //TODO: Fix this
21 | public List Injections { get; set; } = new List();
22 | }
23 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 genesisdotnet
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/ClearCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Genesis.Cli.Commands
9 | {
10 | public class ClearCommand : GenesisCommand
11 | {
12 | public override string Name { get => "clear"; }
13 |
14 | public override string Description => "Clear the execution Chain and flush the Object cache";
15 |
16 | protected override Task OnHelpRequested(string[] args)
17 | {
18 | return base.OnHelpRequested(args);
19 | }
20 |
21 | public override async Task Execute(GenesisContext genesis, string[] args)
22 | {
23 | genesis.Objects.Clear();
24 | Text.GrayLine("Objects have been reset");
25 |
26 | Text.WhiteLine("Clearing the Chain");
27 | genesis.Chain.Clear();
28 |
29 | return await Task.FromResult(new BlankGenesisExecutionResult()); //because nothing broke and we have nothing to report. :| (uh)
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Genesis/MethodGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Xml.Serialization;
5 |
6 | namespace Genesis
7 | {
8 | public enum MethodVisibilities
9 | {
10 | Public,
11 | Private,
12 | Internal,
13 | Protected
14 | }
15 |
16 | public class MethodGraph : Graph
17 | {
18 | public MethodGraph() : base(GraphTypes.Method) { }
19 | [XmlIgnore]
20 | public Type ReturnDataType { get; set; }
21 | public MethodVisibilities MethodVisibility { get; set; } = MethodVisibilities.Public;
22 | public List Parameters { get; } = new List();
23 | public string Name { get; set; }
24 | public bool HasGenericParams { get; set; }
25 | public bool IsGeneric { get; set; }
26 | public string ReturnTypeFormattedName { get; set; }
27 | #pragma warning disable CA1819 // Properties should not return arrays
28 | public string[] FormattedGenericArguments { get; set; } = Array.Empty();
29 | #pragma warning restore CA1819 // Properties should not return arrays
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tools/MSSqlInput-TestTables.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE [dbo].[CoolObjects] (
2 | [Id] INT IDENTITY (1, 1) NOT NULL,
3 | [Description] NVARCHAR (256) NOT NULL,
4 | [IntField] INT NOT NULL,
5 | [BigIntField] BIGINT NOT NULL,
6 | [GuidField] UNIQUEIDENTIFIER NOT NULL,
7 | [BigTextField] TEXT NOT NULL,
8 | [CreatedOn] DATETIME2 (7) NOT NULL,
9 | [ModifiedOn] DATETIME2 (7)
10 | );
11 |
12 | CREATE TABLE [dbo].[ImporantItems] (
13 | [Id] INT IDENTITY (1, 1) NOT NULL,
14 | [Description] NVARCHAR (256) NOT NULL,
15 | [IntField] INT NOT NULL,
16 | [BigIntField] BIGINT NOT NULL,
17 | [GuidField] UNIQUEIDENTIFIER NOT NULL,
18 | [BigTextField] TEXT NOT NULL,
19 | [CreatedOn] DATETIME2 (7) NOT NULL,
20 | [ModifiedOn] DATETIME2 (7)
21 | );
22 |
23 | CREATE TABLE [dbo].[UserSettings] (
24 | [Id] INT IDENTITY (1, 1) NOT NULL,
25 | [Description] NVARCHAR (256) NOT NULL,
26 | [IntField] INT NOT NULL,
27 | [BigIntField] BIGINT NOT NULL,
28 | [GuidField] UNIQUEIDENTIFIER NOT NULL,
29 | [BigTextField] TEXT NOT NULL,
30 | [CreatedOn] DATETIME2 (7) NOT NULL,
31 | [ModifiedOn] DATETIME2 (7)
32 | );
--------------------------------------------------------------------------------
/src/DemoSite/Views/Shared/_CookieConsentPartial.cshtml:
--------------------------------------------------------------------------------
1 | @using Microsoft.AspNetCore.Http.Features
2 |
3 | @{
4 | var consentFeature = Context.Features.Get();
5 | var showBanner = !consentFeature?.CanTrack ?? false;
6 | var cookieString = consentFeature?.CreateConsentCookie();
7 | }
8 |
9 | @if (showBanner)
10 | {
11 |
12 | Use this space to summarize your privacy and cookie use policy. Learn More.
13 |
16 |
17 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProjectFiles/Genesis.Output.ProjectFiles.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | Always
15 |
16 |
17 | Always
18 |
19 |
20 | Always
21 |
22 |
23 | Always
24 |
25 |
26 | Always
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/DemoSite/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/tools/TestInputAssembly/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/TestInputAssembly.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}",
16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17 | "console": "internalConsole",
18 | "stopAtEntry": false
19 | },
20 | {
21 | "name": ".NET Core Attach",
22 | "type": "coreclr",
23 | "request": "attach",
24 | "processId": "${command:pickProcess}"
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/src/DemoSite/Views/Shared/_ValidationScriptsPartial.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
12 |
18 |
19 |
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/PetController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class PetController : ControllerBase
12 | {
13 | public PetController() {} //TODO: Inject something useful
14 |
15 | // GET api/Pet
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new Pet[] { default(Pet), default(Pet) };
20 | }
21 |
22 | // GET api/Pet/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new Pet();
27 | }
28 |
29 | // POST api/Pet
30 | [HttpPost]
31 | public void Post([FromBody] Pet value)
32 | {
33 | }
34 |
35 | // PUT api/Pet/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] Pet value)
38 | {
39 | }
40 |
41 | // DELETE api/Pet/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/TagController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class TagController : ControllerBase
12 | {
13 | public TagController() {} //TODO: Inject something useful
14 |
15 | // GET api/Tag
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new Tag[] { default(Tag), default(Tag) };
20 | }
21 |
22 | // GET api/Tag/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new Tag();
27 | }
28 |
29 | // POST api/Tag
30 | [HttpPost]
31 | public void Post([FromBody] Tag value)
32 | {
33 | }
34 |
35 | // PUT api/Tag/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] Tag value)
38 | {
39 | }
40 |
41 | // DELETE api/Tag/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/DemoSite/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2018 Twitter, Inc.
4 | Copyright (c) 2011-2018 The Bootstrap Authors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/UserController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class UserController : ControllerBase
12 | {
13 | public UserController() {} //TODO: Inject something useful
14 |
15 | // GET api/User
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new User[] { default(User), default(User) };
20 | }
21 |
22 | // GET api/User/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new User();
27 | }
28 |
29 | // POST api/User
30 | [HttpPost]
31 | public void Post([FromBody] User value)
32 | {
33 | }
34 |
35 | // PUT api/User/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] User value)
38 | {
39 | }
40 |
41 | // DELETE api/User/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/OrderController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class OrderController : ControllerBase
12 | {
13 | public OrderController() {} //TODO: Inject something useful
14 |
15 | // GET api/Order
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new Order[] { default(Order), default(Order) };
20 | }
21 |
22 | // GET api/Order/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new Order();
27 | }
28 |
29 | // POST api/Order
30 | [HttpPost]
31 | public void Post([FromBody] Order value)
32 | {
33 | }
34 |
35 | // PUT api/Order/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] Order value)
38 | {
39 | }
40 |
41 | // DELETE api/Order/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/InspectCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using Genesis.Output;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Genesis.Cli.Commands
9 | {
10 | public class InspectCommand : GenesisCommand
11 | {
12 | public override string Name { get => "inspect"; } //I keep typing 'exec' whatever, and it's annoying.
13 |
14 | public override string Description => "Inspect an IGenesisExecutor";
15 |
16 | public override async Task Execute(GenesisContext genesis, string[] args)
17 | {
18 | var btr = new BlankGenesisExecutionResult();
19 |
20 | if (args.Length < 2)
21 | {
22 | Text.White("Specify an Executor "); Text.CliCommandLine("Name");
23 | return btr;
24 | }
25 |
26 | var exeName = args[1];
27 |
28 | //NOTE: Added that default help stuff for commands. Copy / Pasted 'gen' command here ;)
29 |
30 | var exe = GetExecutor(exeName);
31 | await exe.DisplayConfiguration();
32 |
33 | Text.Line();
34 |
35 | return await Task.FromResult(btr);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Genesis/Outputs/DependencyManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 |
6 | #nullable enable
7 |
8 | namespace Genesis.Output
9 | {
10 | public static class DependencyManager
11 | {
12 | public static List LoadDependencies(IOutputExecutor executor)
13 | {
14 | var result = new List();
15 |
16 | var fileName = executor.GetType().Name + GenesisDefaults.DependenciesExtension;
17 |
18 | string t = string.Empty;
19 | if (File.Exists(fileName))
20 | t = File.ReadAllText(fileName);
21 |
22 | var chunks = t.Split(new string[] { Tokens.TemplateSeperator }, StringSplitOptions.RemoveEmptyEntries);
23 |
24 | foreach (var i in chunks)
25 | {
26 | using var rdr = new StringReader(i.TrimStart());
27 |
28 | var objectName = rdr.ReadLine();
29 | var pathFragment = rdr.ReadLine();
30 | var content = rdr.ReadToEnd();
31 |
32 | result.Add(new GenesisDependency(pathFragment, objectName, content));
33 | }
34 |
35 | return result;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Genesis/Inputs/InputExecutor.cs:
--------------------------------------------------------------------------------
1 | using Genesis;
2 | using System.Composition;
3 | using System.Threading.Tasks;
4 |
5 | namespace Genesis.Input
6 | {
7 | ///
8 | /// The primary class responsible for writing out generated code and imported via the core Extensibility Framework (MEF)
9 | ///
10 | [Export(nameof(IInputExecutor), typeof(IInputExecutor))]
11 | public abstract class InputExecutor : GenesisExecutor, IInputExecutor
12 | {
13 | private readonly string commandText = "newpopulator";
14 | public override string CommandText { get => commandText; }
15 |
16 | private readonly string description = "Enter a description for this InputExecutor";
17 | public override string Description { get => description; }
18 |
19 | private readonly string friendlyName = "FriendlyName Can Have Spaces";
20 | public override string FriendlyName { get => friendlyName; }
21 |
22 | public IInputConfiguration Configuration { get; set; } = new InputConfiguration();
23 |
24 | public override async Task Execute(GenesisContext genesis, string[] args)
25 | {
26 | return await Task.FromResult(new InputGenesisExecutionResult());
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/CategoryController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class CategoryController : ControllerBase
12 | {
13 | public CategoryController() {} //TODO: Inject something useful
14 |
15 | // GET api/Category
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new Category[] { default(Category), default(Category) };
20 | }
21 |
22 | // GET api/Category/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new Category();
27 | }
28 |
29 | // POST api/Category
30 | [HttpPost]
31 | public void Post([FromBody] Category value)
32 | {
33 | }
34 |
35 | // PUT api/Category/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] Category value)
38 | {
39 | }
40 |
41 | // DELETE api/Category/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/PetClientController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class PetClientController : ControllerBase
12 | {
13 | public PetClientController() {} //TODO: Inject something useful
14 |
15 | // GET api/PetClient
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new PetClient[] { default(PetClient), default(PetClient) };
20 | }
21 |
22 | // GET api/PetClient/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new PetClient();
27 | }
28 |
29 | // POST api/PetClient
30 | [HttpPost]
31 | public void Post([FromBody] PetClient value)
32 | {
33 | }
34 |
35 | // PUT api/PetClient/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] PetClient value)
38 | {
39 | }
40 |
41 | // DELETE api/PetClient/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/Genesis/Executors/GeneralExecutor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Composition;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Genesis.Executors
8 | {
9 | ///
10 | /// The primary class responsible for general operations that may / may not be dependent on the object graph
11 | ///
12 | [Export(nameof(IGeneralExecutor), typeof(IGeneralExecutor))]
13 | public abstract class GeneralExecutor : GenesisExecutor, IGeneralExecutor
14 | {
15 | private readonly string commandText = "executor";
16 | public override string CommandText { get => commandText; }
17 |
18 | private readonly string description = "Enter a description for this Executor";
19 | public override string Description { get => description; }
20 |
21 | private readonly string friendlyName = "FriendlyName Can Have Spaces";
22 | public override string FriendlyName { get => friendlyName; }
23 |
24 | public IGeneralConfiguration Configuration { get; set; }
25 |
26 | public override async Task Execute(GenesisContext genesis, string[] args)
27 | {
28 | return await Task.FromResult(new BlankGenesisExecutionResult());
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/UserClientController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class UserClientController : ControllerBase
12 | {
13 | public UserClientController() {} //TODO: Inject something useful
14 |
15 | // GET api/UserClient
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new UserClient[] { default(UserClient), default(UserClient) };
20 | }
21 |
22 | // GET api/UserClient/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new UserClient();
27 | }
28 |
29 | // POST api/UserClient
30 | [HttpPost]
31 | public void Post([FromBody] UserClient value)
32 | {
33 | }
34 |
35 | // PUT api/UserClient/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] UserClient value)
38 | {
39 | }
40 |
41 | // DELETE api/UserClient/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetService/AspNetServiceGenerator.gen:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 | using Microsoft.Extensions.Logging;
3 | using Microsoft.FeatureManagement;
4 | using ~DEPS_MODEL_NAMESPACE~;
5 | using ~DEPS_DTO_NAMESPACE~;
6 | using ~DEPS_MAPPING_NAMESPACE~;
7 | using ~DEPS_NAMESPACE~;
8 |
9 | namespace ~NAMESPACE~
10 | {
11 | public interface I~OBJECT_NAME~~OUTPUT_SUFFIX~ : I~OUTPUT_SUFFIX~<~OBJECT_NAME~~DTO_BASECLASS~, ~OBJECT_NAME~, ~KEY_DATATYPE~> { }
12 |
13 | public sealed class ~OBJECT_NAME~~OUTPUT_SUFFIX~ : ~OUTPUT_SUFFIX~<~OBJECT_NAME~~DTO_BASECLASS~, ~OBJECT_NAME~, ~KEY_DATATYPE~>, I~OBJECT_NAME~~OUTPUT_SUFFIX~
14 | {
15 | public override string Name { get => nameof(~OBJECT_NAME~~OUTPUT_SUFFIX~); }
16 |
17 | public ~OBJECT_NAME~~OUTPUT_SUFFIX~(
18 | I~OBJECT_NAME~~REPOSITORY_SUFFIX~ ~OBJECT_NAME_ARGUMENT~~REPOSITORY_SUFFIX~,
19 | I~OBJECT_NAME~~CACHED_REPOSITORY_SUFFIX~ ~OBJECT_NAME_ARGUMENT~~CACHED_REPOSITORY_SUFFIX~,
20 | IFeatureManagerSnapshot featureManagementSnapshot,
21 | ILogger<~OBJECT_NAME~~OUTPUT_SUFFIX~> logger,
22 | IMapper mapper
23 | ) : base(~OBJECT_NAME_ARGUMENT~~REPOSITORY_SUFFIX~, ~OBJECT_NAME_ARGUMENT~~CACHED_REPOSITORY_SUFFIX~, featureManagementSnapshot, logger, mapper)
24 | {
25 |
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/ApiResponseController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class ApiResponseController : ControllerBase
12 | {
13 | public ApiResponseController() {} //TODO: Inject something useful
14 |
15 | // GET api/ApiResponse
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new ApiResponse[] { default(ApiResponse), default(ApiResponse) };
20 | }
21 |
22 | // GET api/ApiResponse/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new ApiResponse();
27 | }
28 |
29 | // POST api/ApiResponse
30 | [HttpPost]
31 | public void Post([FromBody] ApiResponse value)
32 | {
33 | }
34 |
35 | // PUT api/ApiResponse/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] ApiResponse value)
38 | {
39 | }
40 |
41 | // DELETE api/ApiResponse/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/StoreClientController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class StoreClientController : ControllerBase
12 | {
13 | public StoreClientController() {} //TODO: Inject something useful
14 |
15 | // GET api/StoreClient
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new StoreClient[] { default(StoreClient), default(StoreClient) };
20 | }
21 |
22 | // GET api/StoreClient/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new StoreClient();
27 | }
28 |
29 | // POST api/StoreClient
30 | [HttpPost]
31 | public void Post([FromBody] StoreClient value)
32 | {
33 | }
34 |
35 | // PUT api/StoreClient/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] StoreClient value)
38 | {
39 | }
40 |
41 | // DELETE api/StoreClient/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetService/AspNetServiceConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.ApiServiceConfig
7 | {
8 | public class AspNetServiceConfig : GeneratorConfiguration
9 | {
10 | public string DtoNamespace { get; set; } = "Genesis.Common";
11 | public string ModelNamespace { get; set; } = "Genesis.Data.Models";
12 | public string MapperNamespace { get; set; } = "Genesis.Services.Mapping";
13 | public string RepoNamespace { get; set; } = "Genesis.Data.Repositories";
14 | public string CachedRepoNamespace { get; set; } = "Genesis.Data.CachedRepositories";
15 | public string ModelBaseClass { get; set; } = "Model";
16 | public string ObjectBaseClass { get; set; } = "Service";
17 | public string DtoBaseClass { get; set; } = "Dto";
18 | public string MapperSuffix { get; set; } = "Mapper";
19 | public string RepoSuffix { get; set; } = "Repository";
20 | public string CachedRepoSuffix { get; set; } = "CachedRepository";
21 | public string Language { get; set; } = "C#";
22 | public string Overwrite { get; set; } = "all";
23 | public string Preserve { get; set; } = "none";
24 | public bool GenericBaseClass { get; set; } = true;
25 | }
26 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetAutoMapper/AspNetAutoMapperConfig.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Genesis.Output.ApiServiceConfig
7 | {
8 | public class AspNetAutoMapperConfig : GeneratorConfiguration
9 | {
10 | public string DtoNamespace { get; set; } = "Genesis.Common";
11 | public string ModelNamespace { get; set; } = "Genesis.Data.Models";
12 | public string MapperNamespace { get; set; } = "Genesis.Services.Mapping";
13 | public string RepoNamespace { get; set; } = "Genesis.Data.Repositories";
14 | public string CachedRepoNamespace { get; set; } = "Genesis.Data.CachedRepositories";
15 | public string ModelBaseClass { get; set; } = "Model";
16 | public string ObjectBaseClass { get; set; } = "Service";
17 | public string DtoBaseClass { get; set; } = "Dto";
18 | public string MapperSuffix { get; set; } = "Mapper";
19 | public string RepoSuffix { get; set; } = "Repository";
20 | public string CachedRepoSuffix { get; set; } = "CachedRepository";
21 | public string Language { get; set; } = "C#";
22 | public string Overwrite { get; set; } = "all";
23 | public string Preserve { get; set; } = "none";
24 | public bool GenericBaseClass { get; set; } = true;
25 | }
26 | }
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/ApiExceptionController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class ApiExceptionController : ControllerBase
12 | {
13 | public ApiExceptionController() {} //TODO: Inject something useful
14 |
15 | // GET api/ApiException
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new ApiException[] { default(ApiException), default(ApiException) };
20 | }
21 |
22 | // GET api/ApiException/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new ApiException();
27 | }
28 |
29 | // POST api/ApiException
30 | [HttpPost]
31 | public void Post([FromBody] ApiException value)
32 | {
33 | }
34 |
35 | // PUT api/ApiException/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] ApiException value)
38 | {
39 | }
40 |
41 | // DELETE api/ApiException/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/QuestionMarkCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace Genesis.Cli.Commands
9 | {
10 | public class QuestionMarkCommand : GenesisCommand
11 | {
12 | public override string Name { get => "?"; }
13 | public override string Description => "Inception, display this information";
14 | public override string Usage => "?";
15 | public override async Task Execute(GenesisContext genesis, string[] args)
16 | {
17 | await CommandLoader.InitAsync(args);
18 |
19 | Text.Line();
20 | Text.Cyan("Genesis"); Text.GrayLine($" {Program.GetVersionDisplayString()}");
21 | Text.Line();
22 |
23 | foreach(var cmd in CommandLoader.Commands)
24 | {
25 | if (cmd.Name == string.Empty) //default command leaves an empty line otherwise
26 | continue;
27 |
28 | Text.Green($"\t{cmd.Name}"); Text.WhiteLine($"\t\t{cmd.Description}");
29 | }
30 |
31 | Text.Line();
32 |
33 | return await Task.FromResult(new BlankGenesisExecutionResult() { Success = true, Message = "" });
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.SwaggerUrl/Genesis.Input.SwaggerUrl.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | Always
26 |
27 |
28 | Always
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/DemoSite/Controllers/FileParameterController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 |
7 | namespace DemoSite.Controllers
8 | {
9 | [Route("api/[controller]")]
10 | [ApiController]
11 | public class FileParameterController : ControllerBase
12 | {
13 | public FileParameterController() {} //TODO: Inject something useful
14 |
15 | // GET api/FileParameter
16 | [HttpGet]
17 | public ActionResult> Get()
18 | {
19 | return new FileParameter[] { default(FileParameter), default(FileParameter) };
20 | }
21 |
22 | // GET api/FileParameter/5
23 | [HttpGet("{id}")]
24 | public ActionResult Get(int id)
25 | {
26 | return new FileParameter();
27 | }
28 |
29 | // POST api/FileParameter
30 | [HttpPost]
31 | public void Post([FromBody] FileParameter value)
32 | {
33 | }
34 |
35 | // PUT api/FileParameter/5
36 | [HttpPut("{id}")]
37 | public void Put(int id, [FromBody] FileParameter value)
38 | {
39 | }
40 |
41 | // DELETE api/FileParameter/5
42 | [HttpDelete("{id}")]
43 | public void Delete(int id)
44 | {
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/tools/TestInputAssembly/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/TestInputAssembly.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/TestInputAssembly.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "${workspaceFolder}/TestInputAssembly.csproj",
36 | "/property:GenerateFullPaths=true",
37 | "/consoleloggerparameters:NoSummary"
38 | ],
39 | "problemMatcher": "$msCompile"
40 | }
41 | ]
42 | }
--------------------------------------------------------------------------------
/tools/TestInputAssembly/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Genesis;
3 |
4 | namespace TestInputAssembly
5 | {
6 | class Program
7 | {
8 | static void Main(string[] args)
9 | {
10 | Console.WriteLine("Hello World!");
11 | }
12 | }
13 |
14 | [GenesisObject]
15 | public sealed class AttributeTestObjectOne
16 | {
17 | public string TestString { get; set; } = string.Empty;
18 | public byte TestByte { get; set; }
19 |
20 | public short TestShort { get; set; }
21 |
22 | public int TestInt { get; set; }
23 |
24 | public long TestLong { get; set; }
25 |
26 | public DateTime TestDateTime { get; set; }
27 | }
28 |
29 | [GenesisObject]
30 | public sealed class AttributeTestObjectTwo
31 | {
32 | public string TestString { get; set; } = string.Empty;
33 | public byte TestByte { get; set; }
34 |
35 | public short TestShort { get; set; }
36 |
37 | public int TestInt { get; set; }
38 |
39 | public long TestLong { get; set; }
40 |
41 | public DateTime TestDateTime { get; set; }
42 | }
43 |
44 | [GenesisObject]
45 | public sealed class AttributeTestObjectThree
46 | {
47 | public string TestString { get; set; } = string.Empty;
48 | public byte TestByte { get; set; }
49 |
50 | public short TestShort { get; set; }
51 |
52 | public int TestInt { get; set; }
53 |
54 | public long TestLong { get; set; }
55 |
56 | public DateTime TestDateTime { get; set; }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Genesis/ObjectGraph.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Xml.Serialization;
5 |
6 | #nullable enable
7 |
8 | namespace Genesis
9 | {
10 | public class ObjectGraph : Graph, IKeyable
11 | {
12 | public ObjectGraph() : base(GraphTypes.Object) { }
13 | public override GraphTypes GraphType => GraphTypes.Object;
14 | public string Namespace { get; set; } = string.Empty;
15 | public List Attributes { get; set; } = new List();
16 | public List Properties { get; set; } = new List();
17 | public List Methods { get; set; } = new List();
18 | public List Events { get; set; } = new List();
19 | public List Relationships { get; set; } = new List();
20 | public string Name { get; set; } = "OG";
21 | public bool IsKeyProperty { get; set; }
22 | public object KeyId { get; set; } = "0";
23 | public string SourceType { get; set; } = "object";
24 | public bool IsDefault { get { return Properties.Count == 0 && Methods.Count == 0; } }
25 | [XmlIgnore]
26 | public Type BaseType { get; set; } = typeof(object);
27 | public string BaseTypeFormattedName { get; set; } = string.Empty;
28 | public bool IsGeneric { get; set; }
29 | public string[] GenericArgumentTypes { get; set; } = Array.Empty();
30 | public string KeyDataType { get; set; } = "int";
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProtobufService/ProtoServiceGenerator.gen:
--------------------------------------------------------------------------------
1 | using Grpc.Core;
2 | using Microsoft.Extensions.Logging;
3 | using System.Threading.Tasks;
4 | using ~DEPS_SERVICE_NAMESPACE~;
5 | using ~GRPC_NAMESPACE~;
6 | using ~DEPS_DTO_NAMESPACE~;
7 |
8 | namespace ~NAMESPACE~
9 | {
10 | public class ~OBJECT_NAME~GrpcService : ~OBJECT_NAME~ProtoService.~OBJECT_NAME~ServiceBase
11 | {
12 | private readonly ILogger<~OBJECT_NAME~GrpcService> _logger;
13 | ~INJECTION_MEMBERS~
14 |
15 | public ~OBJECT_NAME~GrpcService(ILogger<~OBJECT_NAME~GrpcService> logger, ~INJECTIONS~)
16 | {
17 | _logger = logger;
18 | ~INJECTION_ASSIGNMENT~
19 | }
20 |
21 | public override Task Add~OBJECT_NAME~(~OBJECT_NAME~ request, ServerCallContext context)
22 | {
23 | return Task.FromResult(new SuccessOrFailResult { Result = true });
24 | }
25 |
26 | public override Task<~OBJECT_NAME~> Get~OBJECT_NAME~(~OBJECT_NAME~Key request, ServerCallContext context)
27 | {
28 | return Task.FromResult(new ~OBJECT_NAME~() { Id = request.Id });
29 | }
30 |
31 | public override Task Put~OBJECT_NAME~(~OBJECT_NAME~ request, ServerCallContext context)
32 | {
33 | return Task.FromResult(new SuccessOrFailResult { Result = true });
34 | }
35 |
36 | public override Task Delete~OBJECT_NAME~(~OBJECT_NAME~Key request, ServerCallContext context)
37 | {
38 | return Task.FromResult(new SuccessOrFailResult { Result = true });
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/Genesis/GenesisScope.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 |
5 | namespace Genesis
6 | {
7 | public class GenesisScope
8 | {
9 | public string PromptString { get; private set; }
10 | public List> Executors { get; } = new List>();
11 |
12 | private IGenesisExecutor _currentExecutor;
13 | public IGenesisExecutor CurrentTask
14 | {
15 | get => _currentExecutor;
16 | private set
17 | {
18 | _currentExecutor = value;
19 | PromptString = (_currentExecutor != null)
20 | ? "/" + _currentExecutor.CommandText
21 | : string.Empty;
22 | }
23 | }
24 | public async Task Configure(string propertyName, object value)
25 | {
26 | try
27 | {
28 | if (_currentExecutor == null)
29 | throw new Exception("You're not within a scope. "); //TODO: Elaborate how to set a scope
30 |
31 | _ = await CurrentTask.EditConfig(propertyName, value?.ToString() ?? string.Empty); //for now
32 |
33 | }
34 | catch (Exception e)
35 | {
36 | Text.RedLine($@"{e.Message}");
37 | }
38 | }
39 | public async Task ExitScope()
40 | {
41 | CurrentTask = null;
42 |
43 | await Task.CompletedTask;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/DemoSite/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2 | for details on configuring this project to bundle and minify static web assets. */
3 |
4 | a.navbar-brand {
5 | white-space: normal;
6 | text-align: center;
7 | word-break: break-all;
8 | }
9 |
10 | /* Provide sufficient contrast against white background */
11 | a {
12 | color: #0366d6;
13 | }
14 |
15 | .btn-primary {
16 | color: #fff;
17 | background-color: #1b6ec2;
18 | border-color: #1861ac;
19 | }
20 |
21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link {
22 | color: #fff;
23 | background-color: #1b6ec2;
24 | border-color: #1861ac;
25 | }
26 |
27 | /* Sticky footer styles
28 | -------------------------------------------------- */
29 | html {
30 | font-size: 14px;
31 | }
32 | @media (min-width: 768px) {
33 | html {
34 | font-size: 16px;
35 | }
36 | }
37 |
38 | .border-top {
39 | border-top: 1px solid #e5e5e5;
40 | }
41 | .border-bottom {
42 | border-bottom: 1px solid #e5e5e5;
43 | }
44 |
45 | .box-shadow {
46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
47 | }
48 |
49 | button.accept-policy {
50 | font-size: 1rem;
51 | line-height: inherit;
52 | }
53 |
54 | /* Sticky footer styles
55 | -------------------------------------------------- */
56 | html {
57 | position: relative;
58 | min-height: 100%;
59 | }
60 |
61 | body {
62 | /* Margin bottom by footer height */
63 | margin-bottom: 60px;
64 | }
65 | .footer {
66 | position: absolute;
67 | bottom: 0;
68 | width: 100%;
69 | white-space: nowrap;
70 | line-height: 60px; /* Vertically center the text there */
71 | }
72 |
--------------------------------------------------------------------------------
/src/Genesis/GenesisAssembly.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Reflection;
5 | using System.Runtime.CompilerServices;
6 | using System.Text;
7 |
8 | namespace Genesis
9 | {
10 | public class GenesisAssembly
11 | {
12 | #region Notes on Inlining
13 | // It is important to mark this method as NoInlining, otherwise the JIT could decide
14 | // to inline it into the Main method. That could then prevent successful unloading
15 | // of the plugin because some of the MethodInfo / Type / Plugin.Interface / HostAssemblyLoadContext
16 | // instances may get lifetime extended beyond the point when the plugin is expected to be
17 | // unloaded.
18 | #endregion
19 |
20 | ///
21 | /// Loads an from a that is able to be unloaded.
22 | ///
23 | /// A with the contents of an .
24 | /// The object holding a reference to the .
25 | ///
26 | [MethodImpl(MethodImplOptions.NoInlining)]
27 | public static Assembly FromStream(Stream stream, out WeakReference loadContextWeakReference)
28 | {
29 | var alc = new GenesisAssemblyLoadContext();
30 | loadContextWeakReference = new WeakReference(alc); // Create a weak reference to the AssemblyLoadContext that will allow us to detect when the unload completes.
31 |
32 | return alc.LoadFromStream(stream);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/DemoSite/wwwroot/lib/jquery/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright JS Foundation and other contributors, https://js.foundation/
2 |
3 | This software consists of voluntary contributions made by many
4 | individuals. For exact contribution history, see the revision history
5 | available at https://github.com/jquery/jquery
6 |
7 | The following license applies to all parts of this software except as
8 | documented below:
9 |
10 | ====
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining
13 | a copy of this software and associated documentation files (the
14 | "Software"), to deal in the Software without restriction, including
15 | without limitation the rights to use, copy, modify, merge, publish,
16 | distribute, sublicense, and/or sell copies of the Software, and to
17 | permit persons to whom the Software is furnished to do so, subject to
18 | the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | ====
32 |
33 | All files located in the node_modules and external directories are
34 | externally maintained libraries used by this software which have their
35 | own licenses; we recommend you read them, as their terms may differ from
36 | the terms above.
37 |
--------------------------------------------------------------------------------
/src/Genesis/GenesisConfiguration.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Configuration;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.IO;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Genesis
10 | {
11 | public class GenesisConfiguration : IGenesisConfiguration
12 | {
13 | public static bool ApplyFromJson(Type configType, string filePath, object instance = null)
14 | {
15 | filePath = filePath ?? throw new ArgumentNullException(nameof(filePath), "The full path with filename at the end. (Must exist)");
16 | instance = instance ?? throw new ArgumentNullException(nameof(instance), "This is the instance of the object you want the configuration values mapped to");
17 |
18 | bool result;
19 |
20 | if (File.Exists(filePath))
21 | {
22 | var fileName = Path.GetFileName(filePath);
23 |
24 | Debug.WriteLine($"Configuration found ({fileName}) for '{configType.FullName}'.\n\tApplying to class from [{filePath}]");
25 | var cfg = new ConfigurationBuilder() //TODO: Make configuration less brittle
26 | .SetBasePath(Environment.CurrentDirectory)
27 | .AddJsonFile(filePath)
28 | .Build();
29 | cfg.Bind(instance); //well that was handy
30 | result = true;
31 | }
32 | else
33 | {
34 | result = false;
35 | Debug.WriteLine($"Configuration .json NOT FOUND for {configType.Name}.json for configuration type {configType.FullName}\n\tat [{filePath}]");
36 | }
37 | return result;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/DepsCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using Genesis.Output;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Genesis.Cli.Commands
9 | {
10 | public class DepsCommand : GenesisCommand
11 | {
12 | public override string Name => "deps";
13 | public override string Description => "Manipulate generator dependencies";
14 |
15 | public override async Task Execute(GenesisContext genesis, string[] args)
16 | {
17 | var exe = (IOutputExecutor)GetExecutor(args[1]);
18 | switch (args[2])
19 | {
20 | case "list":
21 | Text.Line();
22 | foreach (var d in exe.Dependencies)
23 | {
24 | Text.YellowLine(d.PathFragment);
25 | Text.White("\t");
26 | Text.Blue(d.Contents.Length.ToString() + " bytes");
27 | Text.Line();
28 | }
29 | break;
30 | case "dump":
31 | await exe.DepositDependencies(exe.Configuration.OutputPath);
32 | Text.Line();
33 | break;
34 | default:
35 | Text.Line();
36 | Text.White("Choose an operation:");
37 | Text.FriendlyText("\tdump", false); Text.WhiteLine("\tWrites dependencies to the filesystem.");
38 | Text.FriendlyText("\tlist", false); Text.WhiteLine("\tDisplays dependency information");
39 | Text.Line();
40 | break;
41 | }
42 |
43 | return await Task.FromResult(new OutputGenesisExecutionResult() { Success = true }); //heh
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextCachedRepositories/CachedRepositoryGenerator.deps:
--------------------------------------------------------------------------------
1 |
2 | CachedRepository
3 | CachedRepository.cs
4 | using Microsoft.Extensions.Caching.Memory;
5 | using System;
6 | using System.Linq;
7 | using System.Threading.Tasks;
8 |
9 | namespace ~DEPS_NAMESPACE~
10 | {
11 | public abstract class ~OUTPUT_SUFFIX~
12 | {
13 |
14 | }
15 |
16 | public abstract class ~OUTPUT_SUFFIX~ : ~OUTPUT_SUFFIX~, IReadOnlyRepository
17 | where TModel : ~OBJECT_BASECLASS~
18 | where TKey : struct
19 | {
20 | private static readonly string _cacheKey = typeof(TModel).Name;
21 |
22 | protected readonly IRepository _repo = null!;
23 | protected readonly IMemoryCache _cache = null!;
24 |
25 | public MemoryCacheEntryOptions CacheOptions { get; private set; }
26 |
27 | //protected CachedRepository(IRepository repository, IDistributedCache cacheObject)
28 | protected CachedRepository(IRepository repository, IMemoryCache cacheObject)
29 | {
30 | _repo = repository;
31 | _cache = cacheObject;
32 |
33 | CacheOptions = new MemoryCacheEntryOptions()
34 | .SetAbsoluteExpiration(relative: TimeSpan.FromSeconds(5000));
35 | }
36 |
37 | public virtual Task GetById(TKey id)
38 | => _cache.GetOrCreate($@"{_cacheKey}-{id}", entry =>
39 | {
40 | entry.SetOptions(CacheOptions);
41 | return _repo.GetById(id);
42 | });
43 |
44 | public virtual Task> Query()
45 | => _cache.GetOrCreate($@"{_cacheKey}", entry =>
46 | {
47 | entry.SetOptions(CacheOptions);
48 | return _repo.Query();
49 | });
50 | }
51 | }
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/HelpCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace Genesis.Cli.Commands
9 | {
10 | public class HelpCommand : GenesisCommand
11 | {
12 | public override string Name { get => "help"; }
13 | public override string Description => "We'll try to";
14 |
15 | public override async Task Execute(GenesisContext genesis, string[] args)
16 | {
17 | Text.Line();
18 | Text.DarkCyanLine("How this works:");
19 | Text.White("*");
20 | Text.YellowLine("\tDiscover Executor interfaces in the libraries that are right next to the cli. (for now)");
21 | Text.CliCommand("\tscan", false);Text.Line();
22 | Text.Yellow("\tAdd an Executor to the chain. "); Text.GrayLine("(probably an Input/Source/Origin)");
23 | Text.CliCommand("\tadd ", false); Text.CliCommand("mssql",false); Text.GrayLine();
24 | Text.Yellow("\tAdd another Executor. "); Text.GrayLine("(Output/Destination/Target)");
25 | Text.CliCommand("\tadd ", false); Text.CliCommand("poco", false); Text.GrayLine();
26 | Text.Yellow("\tExecute the chain sequentially. mssql populates ObjectGraphs, then poco reads them and writes out class files."); Text.GrayLine();
27 | Text.CliCommand("\texec chain ", false); Text.DarkGrayLine("\t\t\t\t(double check config for mssql.ConnectionString");
28 | Text.Line();
29 | Text.Line();
30 | Text.GrayLine("This effectively reads sql schema so that a poco generator can access that schema and do what it needs to. In this case, it's to write c# class files for each of the Sql Table objects.");
31 |
32 | return await Task.FromResult(new BlankGenesisExecutionResult { Success = true, Message = "" }); ;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/CommandLoader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Composition.Convention;
4 | using System.Composition.Hosting;
5 | using System.IO;
6 | using System.Reflection;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using Genesis.Cli.Extensions;
10 |
11 | namespace Genesis.Cli
12 | {
13 | public sealed class CommandLoader
14 | {
15 | public static List Commands { get; } = new List();
16 |
17 | public static async Task InitAsync(string[] args)
18 | {
19 | var assemblies = new List();
20 |
21 | var exeLocation = Path.GetDirectoryName(typeof(Program).Assembly.Location);
22 |
23 | foreach (var file in Directory.EnumerateFiles(exeLocation, "*" + GenesisDefaults.LibraryExtension, SearchOption.TopDirectoryOnly))
24 | assemblies.Add(Assembly.LoadFile(file));
25 |
26 | var conventions = new ConventionBuilder();
27 |
28 | conventions.ForTypesDerivedFrom()
29 | .Export()
30 | .Shared();
31 |
32 | var configuration = new ContainerConfiguration().WithAssemblies(assemblies, conventions);
33 |
34 | using var container = configuration.CreateContainer();
35 | var commands = container.GetExports();
36 |
37 | Commands.Clear();
38 |
39 | foreach (var command in commands)
40 | {
41 | try
42 | {
43 | Commands.Add(command);
44 | await command.InitializeAsync(args); //raises all the commands' OnInitializing(args)
45 | }
46 | catch (Exception ex)
47 | {
48 | Console.ForegroundColor = ConsoleColor.Yellow;
49 | Console.WriteLine($@"Boo, init failed for {command.GetType().Name}. {ex.Message}. It may or may not work...");
50 | Console.ResetColor();
51 | }
52 | }
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/ScanCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using Genesis.Output;
3 | using Genesis.Input;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using Genesis.Executors;
10 |
11 | namespace Genesis.Cli.Commands
12 | {
13 | public class ScanCommand : GenesisCommand
14 | {
15 | public override string Name { get => "scan"; }
16 | public override string Description => "Scan the filesystem for all Executor types within assemblies";
17 |
18 | public override async Task Execute(GenesisContext genesis, string[] args)
19 | {
20 | var result = new BlankGenesisExecutionResult() { Success = true, Message = "" };
21 |
22 | Text.Line();
23 | Text.YellowLine("Scanning for Inputs:");
24 | await InputManager.InitializeInputsAsync(true);
25 |
26 | Text.Line();
27 |
28 | Text.YellowLine("Scanning for Outputs:");
29 | await OutputManager.InitializeGeneratorsAsync(true);
30 |
31 | Text.Line();
32 |
33 | Text.YellowLine("Scanning for General Executors: ");
34 | await GeneralManager.InitializeExecutorsAsync(true);
35 |
36 | Text.Line();
37 |
38 | Console.ForegroundColor = (InputManager.Inputs.Count > 0) ? ConsoleColor.Green : ConsoleColor.Yellow;
39 | Text.White($@"{InputManager.Inputs.Count}");
40 | Text.WhiteLine($" Potential Input(s)");
41 |
42 | Console.ForegroundColor = (OutputManager.Outputs.Count > 0) ? ConsoleColor.Green : ConsoleColor.Yellow;
43 | Text.White($"{OutputManager.Outputs.Count}");
44 | Text.WhiteLine(" Possible Output(s)");
45 |
46 | Console.ForegroundColor = (GeneralManager.Current.Count > 0) ? ConsoleColor.Green : ConsoleColor.Yellow;
47 | Text.White($"{GeneralManager.Current.Count}");
48 | Text.WhiteLine(" General Executor(s)");
49 |
50 | Text.Line();
51 | Text.White("The ");Text.Green("green"); Text.WhiteLine(" text is how you reference an Executor. ");
52 | Text.Line();
53 |
54 | genesis.ScanCount++;
55 |
56 | return await Task.FromResult(result);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Genesis/GenesisContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 |
5 | namespace Genesis
6 | {
7 | public class GenesisContext
8 | {
9 | public GenesisContext()
10 | {
11 | Chain = new ExecutionChain(this);
12 | }
13 | /*
14 | This whole IGenesisExecutionResult thing is worthless and annoying.
15 | */
16 | public static GenesisScope Scope { get; } = new GenesisScope();
17 | public static GenesisContext Current { get; } = new GenesisContext();
18 |
19 | public int ScanCount { get; set; } = 0;
20 |
21 | public List Objects { get; set; } = new List();
22 |
23 |
24 | public ExecutionChain Chain { get; }
25 |
26 | public async Task AddObject(ObjectGraph obj)
27 | {
28 | if (Objects.Contains(obj)) //TODO: Way better compare needed
29 | {
30 | Text.DarkYellowLine($"{obj.Name} exists, not adding.");
31 | return;
32 | }
33 |
34 | Objects.Add(obj);
35 |
36 | Text.White($"Adding Object '"); Text.DarkMagenta(obj.Name); Text.WhiteLine("'");
37 |
38 | await Task.CompletedTask;
39 | }
40 |
41 | public void ClearObjects()
42 | => Objects.Clear();
43 |
44 | public void WriteContextInfo()
45 | {
46 | Text.Line();
47 | Text.DarkMagentaLine("--------------------------------------------------------------------------------".PadLeft(80));
48 | Text.Line();
49 |
50 | Text.White("Execution Chain: " + "\n\t");
51 | Chain.ForEach(e =>
52 | {
53 | Text.CliCommand(e.CommandText, false); Text.White(" -> ");
54 | });
55 | Text.Line(); Text.Line();
56 | Text.White($@"Scans since reset: ");
57 | if (ScanCount > 0)
58 | Text.GreenLine(ScanCount.ToString());
59 | else
60 | Text.YellowLine(ScanCount.ToString());
61 | Text.Line();
62 | Text.White($"Execute an "); Text.FriendlyText("input"); Text.White(" or an "); Text.FriendlyText("output"); Text.White(" using the "); Text.CliCommand("exec"); Text.WhiteLine(" command.");
63 | Text.Line();
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/src/DemoSite/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.AspNetCore.HttpsPolicy;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.DependencyInjection;
10 | using Microsoft.Extensions.Hosting;
11 |
12 | namespace DemoSite
13 | {
14 | public class Startup
15 | {
16 | public Startup(IConfiguration configuration)
17 | {
18 | Configuration = configuration;
19 | }
20 |
21 | public IConfiguration Configuration { get; }
22 |
23 | // This method gets called by the runtime. Use this method to add services to the container.
24 | public void ConfigureServices(IServiceCollection services)
25 | {
26 | services.Configure(options =>
27 | {
28 | // This lambda determines whether user consent for non-essential cookies is needed for a given request.
29 | options.CheckConsentNeeded = context => true;
30 | });
31 |
32 |
33 | services.AddControllersWithViews();
34 | services.AddRazorPages();
35 | }
36 |
37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
38 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
39 | {
40 | if (env.IsDevelopment())
41 | {
42 | app.UseDeveloperExceptionPage();
43 | }
44 | else
45 | {
46 | app.UseExceptionHandler("/Home/Error");
47 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
48 | app.UseHsts();
49 | }
50 |
51 | app.UseHttpsRedirection();
52 | app.UseStaticFiles();
53 |
54 | app.UseCookiePolicy();
55 |
56 | app.UseRouting();
57 |
58 | app.UseAuthorization();
59 |
60 | app.UseEndpoints(endpoints =>
61 | {
62 | endpoints.MapControllerRoute(
63 | name: "default",
64 | pattern: "{controller=Home}/{action=Index}/{id?}");
65 | endpoints.MapRazorPages();
66 | });
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ProjectFiles/ProjectFilesGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.IO;
6 | using System.Text;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using Genesis.Cli;
10 | using Genesis.Output;
11 |
12 | #nullable enable
13 |
14 | namespace Genesis.Output.Poco
15 | {
16 | public class ProjectFilesGenerator : OutputExecutor
17 | {
18 | public override string CommandText => "project-files";
19 | public override string Description => "Generates a project file for each entry in the .gen file";
20 | public override string FriendlyName => "Project File generator";
21 |
22 | public ProjectFilesConfig Config { get; set; } = new ProjectFilesConfig();
23 |
24 | protected override void OnInitialized()
25 | {
26 | Config = (ProjectFilesConfig)Configuration;
27 |
28 | Actions.Add(Tokens.Namespace, (ctx, obj) => Config.Namespace);
29 | }
30 |
31 | public override async Task Execute(GenesisContext genesis, string[] args)
32 | {
33 | var output = Template.Raw;
34 |
35 | foreach (var proj in Config.Projects)
36 | {
37 | var outPath = Path.Combine(proj.Value, proj.Key);
38 |
39 | if (Config.Overwrite == "true")
40 | {
41 | await File.WriteAllTextAsync(outPath.Replace('<', '_').Replace('>', '_'), Template.Raw); //hacky, can't save fileNames with '<' or '>' in the name
42 | Text.White($"Wrote '"); Text.Yellow(outPath); Text.WhiteLine("'");
43 | }
44 | else
45 | {
46 | Text.White($"Skipped writing '"); Text.Yellow(outPath); Text.WhiteLine("' | overwrite = false");
47 | }
48 | }
49 |
50 | var result = new OutputGenesisExecutionResult
51 | {
52 | Success = true
53 | };
54 |
55 | return result;
56 | }
57 |
58 | protected override GenesisDependency OnBeforeWriteDependency(object sender, DependencyEventArgs e)
59 | {
60 | return new GenesisDependency("","",""); //for now
61 | }
62 |
63 | public async Task ExecuteGraph(ObjectGraph objectGraph)
64 | {
65 | await Task.CompletedTask;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Genesis.Cli/Commands/ExecCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Cli.Extensions;
2 | using Genesis.Output;
3 | using Genesis.Input;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Genesis.Cli.Commands
10 | {
11 | public class ExecCommand : GenesisCommand
12 | {
13 | public override string Name { get => "exec"; }
14 |
15 | public override string Description => "Execute!";
16 |
17 | public override async Task Execute(GenesisContext genesis, string[] args)
18 | {
19 | var tmp = (args.Length==1) ? args[0] : args[1];
20 | var frag = (args.Length == 3 && args[2].Equals("fragile", StringComparison.InvariantCultureIgnoreCase));
21 |
22 | var exe = GetExecutor(tmp);
23 |
24 | if(exe != null) //executor name
25 | {
26 | await exe.Execute(genesis, args);
27 | return new BlankGenesisExecutionResult(); //whatever for now
28 | }
29 | else if (args[1] == "chain")
30 | {
31 | var errorCount = 0;
32 |
33 | foreach (var e in genesis.Chain.Execute(args))
34 | {
35 | if (!e?.Success ?? false) //Executors have to return a result with true
36 | errorCount++;
37 | }
38 |
39 | if (errorCount == 0)
40 | {
41 | Text.SuccessGraffiti();
42 | return new OutputGenesisExecutionResult { Success = true };
43 | }
44 | else if (errorCount <= genesis.Chain.Count && !frag)
45 | {
46 | Text.WarningGraffiti();
47 | return new OutputGenesisExecutionResult { Success = false };
48 | }
49 | else if (errorCount <= genesis.Chain.Count && frag)
50 | {
51 | Text.ErrorGraffiti();
52 | return new OutputGenesisExecutionResult { Success = false };
53 | }
54 |
55 | return new BlankGenesisExecutionResult(); //whatever for now
56 | }
57 | else
58 | {
59 | var temp = GetExecutor(args[1]);
60 |
61 | if (temp == null)
62 | throw new InvalidOperationException("Invalid execution: " + args[0] + " " + args[1]);
63 |
64 | return await temp.Execute(genesis, args);
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Genesis/ExecutionChain.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Genesis
8 | {
9 | public class ExecutionChain
10 | {
11 | protected GenesisContext _ctx;
12 | protected LinkedList> ll;
13 |
14 | public int Count { get => ll.Count; }
15 |
16 | public ExecutionChain(GenesisContext genesisContext)
17 | {
18 | _ctx = genesisContext;
19 | ll = new LinkedList>();
20 | }
21 |
22 | public Task Append(IGenesisExecutor executor)
23 | {
24 | ll.AddLast(executor);
25 |
26 | return Task.CompletedTask;
27 | }
28 |
29 | public Task DisplayDetail()
30 | => ForEach(e => {
31 | Text.CliCommand(e.CommandText);
32 | Text.White(" from ");
33 | Text.Assembly(e.GetType().Assembly.GetName().Name);
34 | Text.GrayLine(".");
35 | });
36 |
37 | public Task ForEach(Action> action)
38 | {
39 | var node = ll.First;
40 | while (node != null && node.Value != null)
41 | {
42 | action(node.Value);
43 | node = node.Next;
44 | }
45 |
46 | return Task.CompletedTask;
47 | }
48 |
49 | public List Execute(string[] args)
50 | {
51 | Text.Line();
52 | Text.WhiteLine($"Beginning serial execution of {ll.Count} executors.");
53 |
54 | var results = new List();
55 |
56 | ForEach(e => {
57 | IGenesisExecutionResult result = null;
58 | try
59 | {
60 | Text.Execute($"{e.GetType().Name}"); Text.Line();
61 | result = e.Execute(_ctx, args).GetAwaiter().GetResult(); // no SyncContext hopefully
62 | }
63 | catch (Exception ex)
64 | {
65 | Text.RedLine(ex.Message);
66 | }
67 | finally
68 | {
69 | results.Add(result);
70 | }
71 | });
72 |
73 | return results;
74 | }
75 |
76 | public void Clear()
77 | => ll.Clear();
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetMvcController/MvcControllerGenerator.gen:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Net;
6 | using AutoMapper;
7 | using Microsoft.AspNetCore.Mvc;
8 | using Microsoft.FeatureManagement;
9 | using Microsoft.Extensions.Logging;
10 | using ~DEPS_NAMESPACE~;
11 | using ~DEPS_SERVICE_NAMESPACE~;
12 | using ~DEPS_DTO_NAMESPACE~;
13 | using ~DEPS_MODEL_NAMESPACE~;
14 |
15 | namespace ~NAMESPACE~
16 | {
17 | [Route("api/v{version:apiVersion}/[controller]")]
18 | public class ~OBJECT_NAME~Controller : Controller
19 | {
20 | private readonly I~OBJECT_NAME~~SERVICE_SUFFIX~ _~OBJECT_NAME_ARGUMENT~~SERVICE_SUFFIX~;
21 | private readonly IFeatureManagerSnapshot _features;
22 | private readonly IMapper _mapper;
23 | private readonly ILogger<~OBJECT_NAME~Controller> _logger;
24 |
25 | public ~OBJECT_NAME~Controller(
26 | I~OBJECT_NAME~~SERVICE_SUFFIX~ ~OBJECT_NAME_ARGUMENT~~SERVICE_SUFFIX~,
27 | IFeatureManagerSnapshot featureManagementSnapshot,
28 | IMapper mapper,
29 | ILogger<~OBJECT_NAME~Controller> logger
30 | )
31 | {
32 | _~OBJECT_NAME_ARGUMENT~~SERVICE_SUFFIX~ = ~OBJECT_NAME_ARGUMENT~~SERVICE_SUFFIX~;
33 | _features = featureManagementSnapshot;
34 | _mapper = mapper;
35 | _logger = logger;
36 | }
37 |
38 | // GET api/v#/~OBJECT_NAME~
39 | [HttpGet]
40 | public async Task Get()
41 | {
42 | return Ok(await _~OBJECT_NAME_ARGUMENT~~SERVICE_SUFFIX~.Query());
43 | }
44 |
45 | // GET api/v#/~OBJECT_NAME~/5
46 | [HttpGet("{id}")]
47 | public async Task Get(~KEY_DATATYPE~ id)
48 | {
49 | return Ok(await _~OBJECT_NAME_ARGUMENT~~SERVICE_SUFFIX~.GetById(id));
50 | }
51 |
52 | // POST api/v#/~OBJECT_NAME~
53 | [HttpPost]
54 | public async Task Post([FromBody] ~OBJECT_NAME~Dto obj)
55 | {
56 | return Ok(await _~OBJECT_NAME_ARGUMENT~~SERVICE_SUFFIX~.Upsert(obj));
57 | }
58 |
59 | // PUT api/v#/~OBJECT_NAME~/5
60 | [HttpPut("{id}")]
61 | public IActionResult Put(~KEY_DATATYPE~ id, [FromBody] ~OBJECT_NAME~Dto obj)
62 | {
63 | return Ok(id);
64 | }
65 |
66 | // DELETE api/v#/~OBJECT_NAME~/5
67 | [HttpDelete("{id}")]
68 | public IActionResult Delete(~KEY_DATATYPE~ id)
69 | {
70 | return Ok(id);
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetMvcController/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis.Output.AspNetMvcController
6 | {
7 | public static class Extensions
8 | {
9 | ///
10 | /// Returns a list of interfaces and parameter names seperated by comma for constructor injection
11 | ///
12 | /// List of interface names.
13 | /// A comma delimited list of interfaces for a constructor.
14 | public static string ToInjectionString(this List interfaces)
15 | {
16 | var sb = new StringBuilder();
17 |
18 | interfaces.ForEach(i =>
19 | {
20 | var tmp = i.ToLower();
21 | sb.AppendLine("\t\t\t" + i + " " + tmp[1] + i[2..] + ", ");
22 | });
23 |
24 | var output = sb.ToString();
25 | if (!string.IsNullOrEmpty(output))
26 | output = output[0..^2]; // skip ', ' at the end
27 |
28 | return output;
29 | }
30 |
31 | ///
32 | /// Returns a string containing line seperated class member declarations.
33 | ///
34 | /// List of interface names.
35 | /// A string containing line seperated member declarations.
36 | public static string ToInjectionMembersString(this List interfaces)
37 | {
38 | var sb = new StringBuilder();
39 |
40 | interfaces.ForEach(i =>
41 | {
42 | var tmp = i.ToLower();
43 | sb.AppendLine("\t\t" + i + " _" + tmp[1] + i[2..] + " = default;");
44 | });
45 |
46 | return sb.ToString();
47 | }
48 |
49 | ///
50 | /// Returns a string containing line seperated parameter to member assignments.
51 | ///
52 | /// List of interface names.
53 | /// A string containing line seperated parameter to member assignments.
54 | public static string ToInjectionAssignmentsString(this List interfaces)
55 | {
56 | var sb = new StringBuilder();
57 |
58 | interfaces.ForEach(i =>
59 | {
60 | var tmp = i.ToLower();
61 | sb.AppendLine("\t\t\t_" + tmp[1] + i[2..] + " = " + tmp[1] + i[2..] + ";");
62 | });
63 |
64 | return sb.ToString();
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ReactEditorComponent/Snippets.js:
--------------------------------------------------------------------------------
1 | /*
2 | const schema = yup.object({
3 | firstName: yup.string().ensure().trim()
4 | .required('First Name is required')
5 | .max(255, 'First Name cannot be greater than 255 chars'),
6 | lastName: yup.string().ensure().trim()
7 | .required('Last Name is required')
8 | .max(255, 'Last Name cannot be greater than 255 chars'),
9 | userRoleId: yup.string() // not sure if this is correct or not
10 | .required('Role is required'),
11 | startDate: yup.date()
12 | .typeError('Hire Date is not a valid date')
13 | .required('Hire Date is required'),
14 | userId: yup.string().ensure().trim()
15 | .required('Email is required')
16 | .email('Please enter a valid email address')
17 | .max(255, 'Email cannot be longer than 255 chars')
18 | });
19 |
20 |
21 |
22 |
23 |
24 |
25 | Hire Date
26 |
27 |
28 |
29 |
35 |
36 |
37 | {errors.startDate}
38 |
39 |
40 |
41 |
42 |
43 |
49 |
50 | {staffEducationLevels.map(kw => (
51 |
54 | ))}
55 |
56 |
57 |
58 |
59 |
66 |
67 | {errors.userId}
68 |
69 |
70 |
71 |
72 | */
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetAutoMapper/AspNetAutoMapperGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Text;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | using Genesis.Cli;
9 | using Genesis.Output;
10 |
11 | #nullable enable
12 |
13 | namespace Genesis.Output.ApiServiceConfig
14 | {
15 | public class AspNetAutoMapperGenerator : OutputExecutor
16 | {
17 | public override string CommandText => "aspnet-map";
18 | public override string Description => "AutoMapper mapping profile";
19 | public override string FriendlyName => "Mapper to convert DTOs <-> DbContext Models";
20 |
21 | public AspNetAutoMapperConfig Config { get; set; } = new AspNetAutoMapperConfig();
22 |
23 | private List _lines = new List();
24 |
25 | protected override void OnInitialized()
26 | {
27 | Config = (AspNetAutoMapperConfig)Configuration;
28 | }
29 |
30 | public override async Task Execute(GenesisContext genesis, string[] args)
31 | {
32 | var result = new OutputGenesisExecutionResult();
33 |
34 | if (!Directory.Exists(Config.OutputPath)) //TODO: Worry about the output path in the OutputGenerator base
35 | Directory.CreateDirectory(Config.OutputPath);
36 |
37 | foreach (var obj in genesis.Objects)
38 | await ExecuteGraph(obj);
39 |
40 | var outPath = Path.Combine(Config.OutputPath, "Mapper.cs");
41 |
42 | var output = Template.Raw
43 | .Replace("~MAPPING_CODE~", string.Join(Environment.NewLine, _lines))
44 | .Replace(Tokens.DepsModelNamespace, Config.ModelNamespace)
45 | .Replace(Tokens.DepsDtoNamespace, Config.DtoNamespace)
46 | .Replace(Tokens.DepsNamespace, Config.DepsNamespace)
47 | .Replace(Tokens.Namespace, Config.Namespace);
48 |
49 | File.WriteAllText(outPath, output);
50 |
51 | result.Success = true;
52 |
53 | return result;
54 | }
55 |
56 | public async Task ExecuteGraph(ObjectGraph objectGraph)
57 | {
58 | _lines.Add($"\t\t\tCreateMap<{objectGraph.Name.ToSingular()}, {objectGraph.Name.ToSingular()}{Config.DtoBaseClass}>();");
59 |
60 | Text.White($"Appended '"); Text.Yellow(objectGraph.Name.ToSingular() + Config.MapperSuffix); Text.WhiteLine("' content to AutoMapper class.");
61 |
62 | await Task.CompletedTask;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.ReactEditorComponent/ReactEditorComponentGenerator.gen:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import { Redirect } from 'react-router-dom';
3 | import { Form, Row, Col, ButtonToolbar, Button, Alert, InputGroup } from 'react-bootstrap';
4 | import { Formik } from 'formik';
5 | import InputMask from 'react-input-mask';
6 | import * as yup from 'yup';
7 | import Switch from '../shared/Switch';
8 | import EditActions from '../shared/EditActions';
9 |
10 | const schema = yup.object({
11 | ~PROPERTIES_VALIDATION~
12 | });
13 |
14 | class Edit~OBJECT_NAME~ extends Component {
15 |
16 | constructor(props) {
17 | super(props);
18 | this.state = {
19 | redirectTo: '/~OBJECT_NAME~'
20 | };
21 | }
22 |
23 | render() {
24 | const { staff, editAction, handleCancelEditClick, redirect, apiError, handleFormSubmit, licenseTypes, staffEducationLevels } = this.props;
25 | const { redirectTo } = this.state;
26 |
27 | if (redirect) {
28 | return ;
29 | }
30 |
31 | return (
32 |
36 | {({
37 | handleSubmit,
38 | handleChange,
39 | values,
40 | touched,
41 | errors,
42 | isSubmitting
43 | }) => (
44 |
76 | )}
77 |
78 | );
79 | }
80 | }
81 |
82 | export default Edit~OBJECT_NAME~;
--------------------------------------------------------------------------------
/src/Executors/README.md:
--------------------------------------------------------------------------------
1 | # Executors
2 |
3 | * `This is based on .Net Core 3.1 using C# 8.0`
4 | * [.Net Core 3.1 download](https://dotnet.microsoft.com/download "Download")
5 | * [Visual Studio installer](https://www.visualstudio.com/ "Download Visual Studio")
6 |
7 | An executor is a plugin to Genesis. They execute arbitrary code around a pseudo-context, or shared state. *(not inside of a context)*
8 | Each executor is free to manipulate the ObjectGraph as they choose. Obviously you could be a dick, but that's not the point.
9 |
10 | `````c
11 | //TODO: Get rid of the 'only' two types of executors program flow.
12 | `````
13 |
14 | ## Input
15 |
16 | These are what feed an ObjectGraph context with schema information describing objects.
17 |
18 | * `Genesis.Input.MSSqlDb`
19 |
20 | Reads `MSSql` database schema into ObjectGraphs (max lengths, datatypes, names, etc.)
21 |
22 | * `Genesis.Input.MySqlDb`
23 |
24 | Reads `MySql` database schema into ObjectGraphs (max lengths, datatypes, names, etc.)
25 |
26 | * `Genesis.Input.SwaggerUrl`
27 |
28 | Reads a `swagger.json` schema file into ObjectGraphs (api calls, their models etc)
29 |
30 | * `Genesis.Input.DotNetAssembly`
31 |
32 | You could populate ObjectGraphs off of actual objects from another .Net Core assembly.
33 |
34 | ## Output
35 |
36 | There's a ton of things to potentially do and/or generate. Here's a few...
37 |
38 | * `Genesis.Output.Poco`
39 |
40 | Write out a (P)lain (O)ld (C)# (O)bject file according to whats in the ObjectGraphs.
41 |
42 | * `Genesis.Output.AspNetMvcController`
43 |
44 | A .Net Controller class that is tailored to schema information from the ObjectGraphs
45 |
46 | * `Genesis.Output.AspNetDbContextCachedRepositories`
47 |
48 | Sample caching repository for an Entity that was described in the ObjectGraphs
49 |
50 | * `Genesis.Output.XamarinViewModel`
51 |
52 | Generate a Xamarin Forms based ViewModel with INotifyPropertyChanged support
53 |
54 | * `Genesis.Output.XamarinView`
55 |
56 | Generate the .xaml markup for a Xamarin Forms Create/Edit view.
57 |
58 | * `Genesis.Output.ProtobufEntitiy`
59 |
60 | Generate a simple .proto file with CRUD actions and an entity
61 |
62 | ## General
63 |
64 | General executors basically just inspect and/or manipulate the data in the ObjectGraphs at any point. For debug purposes there is a tools -> dump command that simply writes out the current ObjectGraphs schema to an .xml file in the `Config.OutputDir` of your choice.
65 |
66 | * `Genesis.Executors.GraphTools`
67 |
68 | Tools library for the ObjectGraphs.
69 |
70 | ## Executor Development
71 |
72 | Right now, all of the executors are referenced by the main Cli project to avoid build events and an overcomplicated dev process. They're still MEF'd in though.
73 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/src/Genesis/Executors/GeneralManager.cs:
--------------------------------------------------------------------------------
1 | using Genesis;
2 | using Genesis.Output.Templates;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Composition.Convention;
6 | using System.Composition.Hosting;
7 | using System.Diagnostics;
8 | using System.IO;
9 | using System.Linq;
10 | using System.Reflection;
11 | using System.Text;
12 | using System.Threading.Tasks;
13 |
14 | namespace Genesis.Executors
15 | {
16 | public static class GeneralManager
17 | {
18 | public static List Current { get; set; } = new List();
19 |
20 | public static async Task InitializeExecutorsAsync(bool writeOutputMessages = false)
21 | {
22 | Current.Clear();
23 |
24 | Debug.WriteLine($@"Scanning local directory for OutputExecutor libraries");
25 |
26 | var assemblies = Directory
27 | .EnumerateFiles(Environment.CurrentDirectory, "*" + GenesisDefaults.LibraryExtension, SearchOption.TopDirectoryOnly)
28 | .Select(Assembly.LoadFile)
29 | .ToList();
30 |
31 | var conventions = new ConventionBuilder();
32 |
33 | conventions.ForTypesDerivedFrom()
34 | .Export()
35 | .Shared();
36 |
37 | var configuration = new ContainerConfiguration().WithAssemblies(assemblies, conventions);
38 |
39 | using var container = configuration.CreateContainer();
40 |
41 | var generators = container.GetExports();
42 |
43 | Current.Clear();
44 |
45 | foreach (var generator in generators)
46 | {
47 | Current.Add(generator);
48 |
49 | try
50 | {
51 | await generator.Initialize();
52 |
53 | if (!writeOutputMessages)
54 | continue;
55 |
56 | Text.White($"'"); Text.Green(generator.CommandText); Text.White("' ("); Text.Cyan(generator.FriendlyName); Text.White(") was found in '"); Text.Blue(generator.GetType().Name); Text.White("'... ");
57 | Text.GreenLine("OK");
58 |
59 | Console.ResetColor();
60 | }
61 | catch (Exception exc)
62 | {
63 | if (!writeOutputMessages)
64 | continue;
65 |
66 | Text.CliCommand(generator.CommandText); Text.White(": ");
67 | Console.ForegroundColor = ConsoleColor.Red;
68 | Console.WriteLine(exc.Message);
69 | Console.ResetColor();
70 | }
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/Genesis/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis
6 | {
7 | //Thanks to [https://stackoverflow.com/posts/48008872/revisions] for this solution.
8 | ///
9 | /// Parse a string into an commandline args like Main(string[] args)
10 | ///
11 | public static class StringExtensions
12 | {
13 | public static IEnumerable ToArgs(this string line)
14 | {
15 | char quote = '"';
16 | char escape = '\\';
17 | bool inQuotes = false;
18 | bool inEscape = false;
19 |
20 | var arg = new StringBuilder();
21 |
22 | var argsTotal = 0; // required for "" as an arg but ditch whitespace between args
23 |
24 | for (int i = 0; i < line?.Length; i++)
25 | {
26 | char c = line[i];
27 | if (c == quote)
28 | {
29 | argsTotal++;
30 |
31 | if (inEscape)
32 | {
33 | arg.Append(c); // found \" -> add " to arg
34 | inEscape = false;
35 | }
36 | else if (inQuotes)
37 | inQuotes = false; // end quote
38 | else
39 | inQuotes = true; // start quote
40 | }
41 | else if (c == escape)
42 | {
43 | argsTotal++;
44 |
45 | if (inEscape) // encountered escape char \\
46 | arg.Append(escape + escape);
47 |
48 | inEscape = !inEscape;
49 | }
50 | else if (char.IsWhiteSpace(c))
51 | {
52 | if (inQuotes)
53 | {
54 | argsTotal++;
55 | arg.Append(c); // append whitespace inside quote
56 | }
57 | else
58 | {
59 | if (argsTotal > 0)
60 | yield return arg.ToString();
61 |
62 | argsTotal = 0;
63 | arg.Clear();
64 | }
65 | }
66 | else
67 | {
68 | argsTotal++;
69 | if (inEscape)
70 | {
71 | arg.Append(escape); // encountered non-escaping backslash so add \
72 | argsTotal = 0;
73 | inEscape = false;
74 | }
75 | arg.Append(c);
76 | }
77 | }
78 |
79 | if (argsTotal > 0)
80 | yield return arg.ToString();
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/Genesis/Injector.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Genesis
6 | {
7 | ///
8 | /// Simple sloppy string helper for dependency injection services.
9 | ///
10 | public sealed class GrpcServiceInjector // copy paste isn't extensible
11 | {
12 | public static string GetDeclarationForServiceClass(ObjectGraph og, string suffix = "GrpcService", bool initNullable = true)
13 | => $"\t\t\tprivate readonly {GetServiceInterfaceName(og, suffix)} {GetServiceMemberName(og, suffix)}{((initNullable) ? " = null!" : string.Empty)};";
14 | public static string GetParameterForServiceClass(ObjectGraph og, string suffix = "GrpcService")
15 | => $"{GetServiceInterfaceName(og, suffix)} {GetServiceParamName(og, suffix)}";
16 |
17 | public static string GetAssignmentForServiceClass(ObjectGraph og, string suffix = "GrpcService")
18 | => $"\t\t\t{GetServiceMemberName(og, suffix)} = {GetServiceParamName(og, suffix)};";
19 |
20 | private static object GetServiceMemberName(ObjectGraph og, string suffix)
21 | => $"_{og.Name.ToSingular().ToCamelCase()}{suffix}";
22 |
23 | private static object GetServiceParamName(ObjectGraph og, string suffix)
24 | => $"{og.Name.ToSingular().ToCamelCase()}{suffix}";
25 |
26 | private static object GetServiceInterfaceName(ObjectGraph og, string suffix)
27 | => $"I{og.Name.ToSingular()}{suffix}";
28 | }
29 |
30 | ///
31 | /// Simple sloppy string helper for dependency injection strings.
32 | ///
33 | public sealed class RepoInjector
34 | {
35 | public static string GetDeclarationForObjectRepo(ObjectGraph og, string repoSuffix = "Repository", bool initNullable = true)
36 | => $"\t\t\tprivate readonly {GetRepoInterfaceName(og, repoSuffix)} {GetRepoMemberName(og, repoSuffix)}{((initNullable)? " = null!":string.Empty)};";
37 | public static string GetParameterForObjectRepo(ObjectGraph og, string repoSuffix = "Repository", bool initNullable = true)
38 | => $"{GetRepoInterfaceName(og, repoSuffix)} {GetRepoParamName(og, repoSuffix)}";
39 |
40 | public static string GetAssignmentForObjectRepo(ObjectGraph og, string repoSuffix = "Repository")
41 | => $"\t\t\t{GetRepoMemberName(og, repoSuffix)} = {GetRepoParamName(og, repoSuffix)};";
42 |
43 | private static object GetRepoMemberName(ObjectGraph og, string repoSuffix)
44 | => $"_{og.Name.ToSingular().ToCamelCase()}{repoSuffix}";
45 |
46 | private static object GetRepoParamName(ObjectGraph og, string repoSuffix)
47 | => $"{og.Name.ToSingular().ToCamelCase()}{repoSuffix}";
48 |
49 | private static object GetRepoInterfaceName(ObjectGraph og, string repoSuffix)
50 | => $"I{og.Name.ToSingular()}{repoSuffix}";
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Executors/Genesis.Executors.GraphTools/GraphToolsExecutor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Net;
6 | using System.Runtime.CompilerServices;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Xml.Serialization;
10 | using Genesis.Output;
11 |
12 | namespace Genesis.Executors.GraphTools
13 | {
14 | public class GraphToolsExecutor : GeneralExecutor
15 | {
16 | private static readonly XmlSerializer _serializer = new XmlSerializerFactory().CreateSerializer(typeof(List));
17 |
18 | public override string CommandText => "tools";
19 | public override string Description => "Tools and utilities for ObjectGraph interaction";
20 | public override string FriendlyName => "ObjectGraph Tools & Utilities";
21 |
22 | public GraphToolsConfig Config { get; set; } = new GraphToolsConfig();
23 |
24 | protected override void OnInitialized()
25 | {
26 | Config = (GraphToolsConfig)Configuration;
27 | }
28 |
29 | public override async Task Execute(GenesisContext genesis, string[] args)
30 | {
31 | if(args.Length == 2)
32 | {
33 | WriteUsage();
34 | return await Task.FromResult(new BlankGenesisExecutionResult());
35 | }
36 |
37 | _ = args[2].ToLower() switch
38 | {
39 | "--dump" => WriteObjectGraphToStorage(genesis),
40 | _ => WriteUsage()
41 | };
42 | return await Task.FromResult(new BlankGenesisExecutionResult());
43 | }
44 |
45 | private static bool WriteUsage()
46 | {
47 | Text.YellowLine("Graph Tools Usage");
48 | Text.WhiteLine();
49 | Text.WhiteLine("--dump Writes the ObjectGraphs content to Xml");
50 | Text.WhiteLine("--clear Empties the current ObjectGraphs collection");
51 | Text.WhiteLine();
52 | return true; //w
53 | }
54 |
55 | private bool WriteObjectGraphToStorage(GenesisContext genesis)
56 | {
57 |
58 | var outDir = Path.Combine(Environment.CurrentDirectory, @"Output");
59 | if (!Directory.Exists(outDir))
60 | Directory.CreateDirectory(outDir);
61 |
62 | var d = DateTime.UtcNow;
63 | var fileName = $"ObjectGraphDump_{d.Day}d-{d.Hour}h-{d.Minute}m-{d.Second}s-{d.Millisecond}ms.xml";
64 | var outputFilePath = Path.Combine(outDir, fileName);
65 |
66 | using var stream = File.OpenWrite(outputFilePath);
67 | stream.Seek(0, SeekOrigin.Begin);
68 | _serializer.Serialize(stream, genesis.Objects);
69 |
70 | Text.YellowLine($"ObjectGraph written to [{outputFilePath}]");
71 | return true;
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetMvcController/MvcControllerGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Threading.Tasks;
3 |
4 | #nullable enable
5 |
6 | namespace Genesis.Output.AspNetMvcController
7 | {
8 | public class MvcControllerGenerator : OutputExecutor
9 | {
10 | public override string CommandText => "aspnet-mvc-con";
11 | public override string Description => "Generates an Asp.Net Controller based on an entity.";
12 | public override string FriendlyName => "Asp.Net MvcController";
13 |
14 | public MvcControllerConfig Config { get; set; } = new MvcControllerConfig();
15 |
16 | protected override void OnInitialized()
17 | {
18 | Config = (MvcControllerConfig)Configuration;
19 | }
20 |
21 | public override async Task Execute(GenesisContext genesis, string[] args)
22 | {
23 | if (!Directory.Exists(Config.OutputPath))
24 | Directory.CreateDirectory(Config.OutputPath);
25 |
26 | var path = !string.IsNullOrEmpty(Config.DepsPath) && Directory.Exists(Config.DepsPath)
27 | ? Config.DepsPath
28 | : Config.OutputPath;
29 |
30 | await DepositDependencies(path);
31 |
32 | foreach (var obj in genesis.Objects)
33 | await ExecuteGraph(obj);
34 |
35 | return new OutputGenesisExecutionResult();
36 | }
37 |
38 | public Task ExecuteGraph(ObjectGraph objectGraph)
39 | {
40 | var entityName = objectGraph.Name.ToSingular();
41 |
42 | var output = Template.Raw
43 | .Replace(Tokens.Namespace, Config.Namespace)
44 | .Replace(Tokens.ObjectName, entityName)
45 | .Replace(Tokens.ObjectNameAsArgument, entityName.ToCorrectedCase())
46 | .Replace(Tokens.OutputSuffix, Config.OutputSuffix)
47 | .Replace(Tokens.ServiceSuffix, Config.ServiceSuffix)
48 | .Replace(Tokens.DtoBaseClass, Config.DtoSuffix)
49 | .Replace(Tokens.KeyDataType, objectGraph.KeyDataType.ToCodeDataType())
50 | .Replace(Tokens.DepsNamespace, Config.DepsNamespace)
51 | .Replace(Tokens.DepsDtoNamespace, Config.DepsDtoNamespace)
52 | .Replace(Tokens.DepsServiceNamespace, Config.DepsServiceNamespace)
53 | .Replace(Tokens.DepsModelNamespace, Config.DepsModelNamespace)
54 | ;
55 |
56 | var path = Path.Combine(Config.OutputPath, $@"{entityName}{Config.OutputSuffix}.cs");
57 |
58 | File.WriteAllText(path, output);
59 |
60 | Text.White($"Wrote '"); Text.Yellow(path); Text.WhiteLine("'");
61 |
62 | return Task.CompletedTask;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.AspNetDbContextRepositories/RepositoryGenerator.deps:
--------------------------------------------------------------------------------
1 |
2 | IReadOnlyRepository
3 | IReadOnlyRepository.cs
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 |
7 | namespace ~DEPS_NAMESPACE~
8 | {
9 | public interface I~OUTPUT_SUFFIX~ { }
10 |
11 | public interface IReadOnly~OUTPUT_SUFFIX~ : I~OUTPUT_SUFFIX~
12 | where TModel : ~OBJECT_BASECLASS~
13 | where TKey : struct
14 | {
15 | Task GetById(TKey id);
16 | Task> Query();
17 | }
18 | }
19 |
20 | IRepository
21 | IRepository.cs
22 | using System.Collections.Generic;
23 | using System.Linq;
24 | using System.Threading.Tasks;
25 |
26 | namespace ~DEPS_NAMESPACE~
27 | {
28 | public interface I~OUTPUT_SUFFIX~ : IReadOnly~OUTPUT_SUFFIX~
29 | where TModel : ~OBJECT_BASECLASS~
30 | where TKey : struct
31 | {
32 | void CancelAllOperations(bool throwOnFirstException);
33 |
34 | Task Upsert(TModel model);
35 | Task Delete(TKey model);
36 | Task AddRange(IEnumerable models);
37 | Task SaveChanges(string currentUser);
38 | }
39 | }
40 |
41 | Repository
42 | Repository.cs
43 | using Microsoft.EntityFrameworkCore;
44 | using System.Collections.Generic;
45 | using System.Linq;
46 | using System.Threading;
47 | using System.Threading.Tasks;
48 |
49 | namespace ~DEPS_NAMESPACE~
50 | {
51 | public abstract class ~OUTPUT_SUFFIX~ { }
52 |
53 | public abstract class ~OUTPUT_SUFFIX~ : ~OUTPUT_SUFFIX~, I~OUTPUT_SUFFIX~
54 | where TModel : ~OBJECT_BASECLASS~
55 | where TKey : struct
56 | {
57 | private readonly CancellationTokenSource _tokenSource = new CancellationTokenSource();
58 |
59 | protected ~OUTPUT_SUFFIX~(DbContext context)
60 | => DbContext = context;
61 |
62 | public DbContext DbContext { get; } = null!;
63 |
64 | public virtual void CancelAllOperations(bool throwOnFirstException = false)
65 | => _tokenSource.Cancel(throwOnFirstException);
66 |
67 | public virtual Task AddRange(IEnumerable models)
68 | => DbContext.Set().AddRangeAsync(models, _tokenSource.Token);
69 |
70 | public virtual Task> Query()
71 | => Task.FromResult(DbContext.Set().AsAsyncQueryable());
72 |
73 | public virtual Task Delete(TKey id)
74 | => Task.CompletedTask;
75 |
76 | public virtual Task GetById(TKey id)
77 | => Task.FromResult(DbContext.Set().Find(id));
78 |
79 | public virtual Task Upsert(TModel model)
80 | => Task.FromResult(model);
81 |
82 | protected virtual Task Add(string user, TModel model)
83 | => Task.FromResult(DbContext.Set().Add(model).Entity);
84 |
85 | public virtual Task SaveChanges(string user)
86 | => DbContext.SaveChangesAsync(_tokenSource.Token);
87 | }
88 | }
--------------------------------------------------------------------------------
/src/Executors/Input/Genesis.Input.DotNetAssembly/AssemblyInput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Runtime.Loader;
6 | using System.Threading.Tasks;
7 |
8 | namespace Genesis.Input.DotNetAssembly
9 | {
10 | public class AssemblyInput : InputExecutor
11 | {
12 | public override string CommandText => "netlib";
13 | public override string FriendlyName => ".Net Assembly";
14 | public override string Description => "Create graph entries from public classes in a .Net core assembly";
15 |
16 | public AssemblyInputConfig Config { get; set; } = new AssemblyInputConfig();
17 |
18 | protected override void OnInitialized(/*, string[] args */) //TODO: Pass args to the init
19 | {
20 | Config = (AssemblyInputConfig)Configuration;
21 | }
22 |
23 | public override async Task Execute(GenesisContext genesis, string[] args)
24 | {
25 | var result = new BlankGenesisExecutionResult();
26 |
27 | var alc = new AssemblyLoadContext("DotNetAssembly", true);
28 |
29 | using var stream = File.OpenRead(Config.AssemblyPath);
30 |
31 | var asm = alc.LoadFromStream(stream);
32 |
33 | if (Config.OnlyGenesisDecorations)
34 | {
35 | foreach(var t in asm.DefinedTypes.Where(w => // pull objects with GenesisObject attribute
36 | w.CustomAttributes.SingleOrDefault(ca => ca.AttributeType == typeof(GenesisObjectAttribute)) != null))
37 | {
38 | InsertGraphFromType(genesis, t);
39 | }
40 |
41 | }
42 | else // use all public objects
43 | {
44 | foreach (var t in asm.DefinedTypes)
45 | {
46 | InsertGraphFromType(genesis, t);
47 | }
48 | }
49 |
50 | return await Task.FromResult(result);
51 | }
52 |
53 | private void InsertGraphFromType(GenesisContext genesis, TypeInfo type)
54 | {
55 | var og = new ObjectGraph {
56 | Name = type.Name,
57 | BaseType = type.BaseType!,
58 | };
59 |
60 | foreach(var p in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
61 | {
62 | og.Properties.Add(new PropertyGraph
63 | {
64 | Name = p.Name,
65 | SourceType = p.PropertyType.Name,
66 | GetterVisibility = (p.IsPublic("get"))
67 | ? MethodVisibilities.Public
68 | : MethodVisibilities.Private, //TODO: change to MethodInfo.IsPublic...
69 | SetterVisibility = (p.IsPublic("set"))
70 | ? MethodVisibilities.Public
71 | : MethodVisibilities.Private,
72 | });
73 | }
74 | genesis.Objects.Add(og);
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/Executors/Output/Genesis.Output.XamarinView/XVGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using Genesis;
8 | using Genesis.Output;
9 |
10 | namespace Genesis.Output.Poco
11 | {
12 | public class XVGenerator : OutputExecutor
13 | {
14 | public override string CommandText => "xv";
15 | public override string Description => "Generates a Xamarin.Forms View with fields for each property";
16 | public override string FriendlyName => "Xamarin.Forms Create/Edit View (XAML)";
17 |
18 | public XVConfig Config { get; set; }
19 |
20 | protected override void OnInitialized()
21 | {
22 | Config = (XVConfig)Configuration;
23 | }
24 |
25 | public override async Task Execute(GenesisContext genesis, string[] args)
26 | {
27 | var result = new OutputGenesisExecutionResult();
28 |
29 | foreach (var obj in genesis.Objects)
30 | {
31 | await ExecuteGraph(obj);
32 | }
33 |
34 | return result;
35 | }
36 |
37 | public async Task ExecuteGraph(ObjectGraph objectGraph)
38 | {
39 | var tmp = this.Template;
40 |
41 | if (Directory.Exists(OutputPath))
42 | Directory.CreateDirectory(OutputPath);
43 |
44 | Thread.Sleep(100); //below fails saying directory doesn't exist... even though ^ runs fine?!
45 |
46 |
47 | //TODO: Output types are still sourcetypes, not poco types
48 |
49 | var output = tmp.Raw.Replace(Tokens.Namespace, Config.Namespace) //TODO: Templating engine? / razor etc would be cool ..|., T4
50 | .Replace(Tokens.ObjectName, objectGraph.Name.ToSingular())
51 | .Replace(Tokens.PropertiesStub, GetPropertiesReplacement(objectGraph.Properties));
52 |
53 | var subPath = Path.Combine(OutputPath, "Xamarin.Views"); //use cli to change this...
54 |
55 | if (!Directory.Exists(subPath))
56 | Directory.CreateDirectory(subPath);
57 |
58 | await Task.Delay(100); //timing or something weirdness
59 |
60 | File.WriteAllText(Path.Combine(subPath, objectGraph.Name.ToSingular() + ".cs"), output);
61 | }
62 |
63 | private string GetPropertiesReplacement(List properties) //TODO: Figure out something for more configuration of the generators
64 | {
65 | string template = Environment.NewLine; //TODO: Properties for Xamarin Forms View XAML
66 |
67 | var sb = new StringBuilder();
68 |
69 | foreach (var p in properties)
70 | {
71 | if (p.SourceType != "UNKNOWN")
72 | sb.AppendLine(template.Replace(Tokens.PropertyDataType, p.SourceType)
73 | .Replace(Tokens.PropertyName, p.Name)
74 | .Replace(Tokens.PropertyMemberName, p.Name.ToCorrectedCase()));
75 | }
76 |
77 | return sb.ToString();
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/Genesis.Cli.Extensions/GenesisCommand.cs:
--------------------------------------------------------------------------------
1 | using Genesis.Output;
2 | using Genesis.Input;
3 | using System;
4 | using System.Diagnostics;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using Genesis.Executors;
8 |
9 | namespace Genesis.Cli.Extensions
10 | {
11 | public abstract class GenesisCommand : IGenesisCommand
12 | {
13 | public abstract string Name { get; }
14 | public virtual string HelpTemplate { get; } = "-?|-h|--help";
15 | public abstract Task Execute(GenesisContext genesis, string[] args);
16 | public virtual string Usage { get; } = "command parameter [[0] [1] [2]]"; //or something
17 | public abstract string Description { get; }
18 |
19 | public Task InitializeAsync(string[] args)
20 | {
21 | Debug.WriteLine($@"{GetType().Name}.{nameof(InitializeAsync)}");
22 |
23 | return OnInitializing(args);
24 | }
25 |
26 | ///
27 | /// Tells the command to check and see if they should write a help command to the screen
28 | ///
29 | ///
30 | ///
31 | public Task ProcessHelpCommand(string[] args)
32 | {
33 | if (HelpWasRequested(args))
34 | {
35 | Debug.WriteLine($@"{GetType().Name}.{nameof(ProcessHelpCommand)}");
36 | OnHelpRequested(args);
37 | }
38 |
39 | return Task.CompletedTask;
40 | }
41 |
42 | protected virtual Task OnInitializing(string[] args)
43 | {
44 | //dump dependencies from a convention?
45 | return Task.CompletedTask;
46 | }
47 |
48 | ///
49 | /// Occurs when - command occurs with no args in [1] or later, or has -h, -help, --help
50 | /// Override this to write out a help page
51 | ///
52 | ///
53 | ///
54 | protected virtual Task OnHelpRequested(string[] args)
55 | {
56 | return Task.CompletedTask;
57 | }
58 |
59 | public IGenesisExecutor GetExecutor(string executorName)
60 | {
61 | var exe = (IGenesisExecutor)InputManager.Inputs.Where(w => w.CommandText.Equals(executorName, StringComparison.Ordinal)).SingleOrDefault();
62 |
63 | if (exe == null)
64 | exe = OutputManager.Outputs.Where(w => w.CommandText.Equals(executorName, StringComparison.Ordinal)).SingleOrDefault();
65 |
66 | if(exe == null)
67 | exe = GeneralManager.Current.Where(w => w.CommandText.Equals(executorName, StringComparison.Ordinal)).SingleOrDefault();
68 |
69 | return exe;
70 | }
71 | #region Helper Methods
72 |
73 | private const string helpArguments = "-h,-?,--help";
74 | private string[] HelpArguments { get => helpArguments.Split(','); }
75 |
76 | ///
77 | /// Checks the arguments for a '-h', --help, or -?
78 | ///
79 | /// string array of arguments from the REPL or script
80 | /// true if a help option/argument was matched, otherwise false
81 | protected bool HelpWasRequested(string[] args)
82 | => (args.Length == 2 && HelpArguments.Contains(args[1].ToLower()));
83 | #endregion
84 | }
85 | }
--------------------------------------------------------------------------------
/src/Genesis/GenesisExecutor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Reflection;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using Genesis;
9 | using Genesis.Output;
10 |
11 | namespace Genesis
12 | {
13 | public abstract class GenesisExecutor : IGenesisExecutor
14 | {
15 | public virtual string CommandText => throw new NotImplementedException();
16 |
17 | public virtual string Description => throw new NotImplementedException();
18 |
19 | public virtual string FriendlyName => throw new NotImplementedException();
20 |
21 | public virtual bool Initialized { get; protected set; }
22 |
23 | public Task Initialize()
24 | {
25 | Initialized = false;
26 |
27 | OnInitialized();
28 |
29 | //TODO: Load Key / Action pairs from .genesis script
30 |
31 | Initialized = true;
32 |
33 | return Task.CompletedTask;
34 | }
35 |
36 | protected virtual void OnInitialized()//TODO: Pass args[] to OutputExecutor.OnInitialized
37 | {
38 |
39 | }
40 |
41 | public async virtual Task DisplayConfiguration()
42 | {
43 | var cfgObj = ConfigObject();
44 | var cfgObjType = cfgObj.GetType();
45 |
46 | Text.WhiteLine();
47 | Text.CliCommand(CommandText);
48 | Text.White(" configuration type is: "); Text.CyanLine($"{cfgObjType.Name}");
49 |
50 | foreach (var p in cfgObjType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
51 | {
52 | var val = cfgObjType.GetProperty(p.Name)?.GetValue(cfgObj);
53 |
54 | Text.Yellow($"\t{p.Name}: ");
55 | Text.DarkBlue(p.PropertyType.Name);
56 | Text.White(":");
57 | Text.DarkYellowLine($"{(val != null ? val is string ? $"\"{val}\"" : val : $"")}");
58 | }
59 |
60 | await Task.CompletedTask;
61 | }
62 |
63 | public async virtual Task EditConfig(string propertyName, TPropertyType value)
64 | {
65 | var err = false;
66 | Type cfgType = null;
67 | try
68 | {
69 | var cfg = ConfigObject();
70 | cfgType = cfg.GetType();
71 |
72 | if (value.GetType().IsAssignableFrom(typeof(string)))
73 | {
74 | var bsalloc = value.ToString().TrimStart('"').TrimEnd('"');
75 | cfgType.GetProperty(propertyName)?.SetValue(cfg, bsalloc);
76 | }
77 | else //feels ghetto to remove quotes like this...
78 | {
79 | cfgType.GetProperty(propertyName)?.SetValue(cfg, value);
80 | }
81 |
82 | //Text.Green(cfgType.Name); Text.White("."); Text.Cyan(propertyName); Text.WhiteLine(" was updated.");
83 | }
84 | catch (NullReferenceException)
85 | {
86 | Text.Red($"No property called '");Text.Cyan(propertyName);Text.RedLine($"' on {cfgType.Name}");
87 | err = true;
88 | }
89 | return await Task.FromResult(!err);
90 | }
91 |
92 |
93 | protected object ConfigObject()
94 | => GetType().GetProperty("Config").GetValue(this);
95 |
96 | public abstract Task Execute(GenesisContext genesis, string[] args);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/Genesis/Outputs/Generator.cs:
--------------------------------------------------------------------------------
1 | using Genesis;
2 | using Genesis.Output.Templates;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Composition;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Reflection;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 |
12 | namespace Genesis.Output
13 | {
14 | ///
15 | /// The primary class responsible for writing out generated code and imported via the core Extensibility Framework (MEF)
16 | ///
17 | [Export(nameof(IOutputExecutor), typeof(IOutputExecutor))]
18 | public abstract class OutputExecutor : GenesisExecutor, IOutputExecutor
19 | {
20 | private readonly string commandText = "newgenerator";
21 | public override string CommandText { get => commandText; }
22 |
23 | private readonly string description = "Enter a description for this OutputExecutor";
24 | public override string Description { get => description; }
25 |
26 | private readonly string friendlyName = "FriendlyName Can Have Spaces";
27 |
28 | public IList _deps = new List();
29 |
30 | public override string FriendlyName { get => friendlyName; }
31 |
32 | public virtual IGeneratorTemplate Template { get; set; } = new StringTemplate("Template contains text loaded from a source"); //for now
33 | public virtual string OutputPath { get; set; } = Path.Combine(Environment.CurrentDirectory, "Output");
34 |
35 | public IOutputConfiguration Configuration { get; set; } = new GeneratorConfiguration();
36 |
37 | public IList Dependencies { get => _deps; }
38 |
39 | public IDictionary> Actions { get; } = new Dictionary>();
40 |
41 | public Task DepositDependencies(string outputRoot = "")
42 | {
43 | try
44 | {
45 | foreach (var dependency in _deps)
46 | {
47 | var modifiedDep = OnBeforeWriteDependency(this, new DependencyEventArgs((GenesisDependency)dependency));
48 |
49 | var loc = ((GeneratorConfiguration)Configuration).DepsPath;
50 |
51 | var directory = !string.IsNullOrEmpty(loc)
52 | ? loc : !string.IsNullOrEmpty(outputRoot)
53 | ? outputRoot
54 | : ((GeneratorConfiguration)Configuration).OutputPath;
55 |
56 | if (!Directory.Exists(directory))
57 | Directory.CreateDirectory(directory);
58 |
59 | var filename = dependency.PathFragment.TrimStart('.').TrimStart('/').TrimStart('\\');
60 |
61 | var path = Path.Combine(directory, filename);
62 |
63 | File.WriteAllText(path, modifiedDep.Contents, Encoding.UTF8);
64 |
65 | Text.Gray($"Wrote ["); Text.DarkYellow(path); Text.GrayLine("]");
66 | }
67 | Text.GreenLine($"Wrote {_deps.Count} dependencies to their respective paths.");
68 | return Task.FromResult(true);
69 | }
70 | catch (Exception e)
71 | {
72 | Text.RedLine(e.Message);
73 | return Task.FromResult(false);
74 | }
75 | }
76 |
77 | public Task AttachDependencies(IList deps)
78 | {
79 | _deps = deps;
80 |
81 | return Task.CompletedTask;
82 | }
83 |
84 | ///
85 | /// Return a modified dependency
86 | ///
87 | protected virtual GenesisDependency OnBeforeWriteDependency(object sender, DependencyEventArgs e)
88 | => e.Dependency;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------