Ejemplo n.º 1
0
        static void Rebuild(string text, FileInfo fileInfo)
        {
            var dsl       = text;
            var generator = new TemplatedGenerator
            {
                GenerateInterfaceForEntityWithModifiers = "?",
                TemplateForInterfaceName   = "public interface I{0}Aggregate",
                TemplateForInterfaceMember = "void When({0} c);",
                ClassNameTemplate          = @"[DataContract(Namespace = {1})]
public partial record {0}",
                MemberTemplate             = "[DataMember(Order = {0})] public {1} {2} {{ get; init; }}",
            };

            File.WriteAllText(Path.ChangeExtension(fileInfo.FullName, "cs"), GeneratorUtil.Build(dsl, generator));

            File.WriteAllText(
                Path.Combine(fileInfo.DirectoryName, "IsExternalInit.cs"),
                @"// Zie https://stackoverflow.com/a/64749403 voor uitleg waarom IsExternalInit noodzakelijk is.
#if NETFRAMEWORK || NETSTANDARD
namespace System.Runtime.CompilerServices
{
    internal static class IsExternalInit {}
}
#endif");
        }
Ejemplo n.º 2
0
        static void Rebuild(string text, string fullPath)
        {
            var dsl       = text;
            var generator = new TemplatedGenerator
            {
                GenerateInterfaceForEntityWithModifiers = "?",
                TemplateForInterfaceName   = "public interface I{0}Aggregate",
                TemplateForInterfaceMember = "void When({0} c);",
                ClassNameTemplate          = @"[DataContract(Namespace = {1})]
public partial class {0}",
                MemberTemplate             = "[DataMember(Order = {0})] public {1} {2} {{ get; private set; }}",
            };


            File.WriteAllText(Path.ChangeExtension(fullPath, "cs"), GeneratorUtil.Build(dsl, generator));
        }