コード例 #1
0
 public void TestGenerateLppl()
 {
     var options = new GeneratorOptions();
       var generator = new Generator(options);
       var generated = generator.Generate();
       Console.WriteLine(generated.ToListPlot());
 }
コード例 #2
0
 public void TestGeneratePl()
 {
     var options = new GeneratorOptions
       {
     Function = x => new Pl().Evaluate(x)
       };
       var generator = new Generator(options);
       var generated = generator.Generate();
       Console.WriteLine(generated.ToListPlot());
 }
コード例 #3
0
ファイル: LifecycleContext.cs プロジェクト: skrymsli/Swasey
        public LifecycleContext(GeneratorOptions opts)
            : this(opts.ApiNamespace, opts.ModelNamespace, opts.Loader, opts.OperationWriter, opts.EnumWriter, opts.ModelWriter)
        {
            State = LifecycleState.Continue;

            ApiEnumTemplate = SwaseyEngine.Compile(opts.ApiEnumTemplate);
            ApiModelTemplate = SwaseyEngine.Compile(opts.ApiModelTemplate);
            ApiOperationTemplate = SwaseyEngine.Compile(opts.ApiOperationTemplate);

            OperationFilter = opts.OperationFilter ?? Defaults.DefaultOperationFilter;
            OperationParameterFilter = opts.OperationParameterFilter ?? Defaults.DefaultOperationParameterFilter;
        }
コード例 #4
0
        public void GenerateScriptTagFromStream()
        {
            // Arrange
            var options = new GeneratorOptions();
            var coreGenerator = new CoreGenerator(options, new Mock<IFilesProvider>().Object);
            var stream = GetStreamForContent("foo");

            // Act
            var tag = coreGenerator.GenerateScriptTagFromStream(stream, "bar");

            // Assert
            Assert.Equal(
                @"<script type=""text/html"" id=""bar-tmpl"">foo</script>",
                tag);
        }
コード例 #5
0
        public void TestLinearOptimizePl()
        {
            var pl = new Pl();

              var options = new GeneratorOptions
              {
            Function = pl.Evaluate,
            ErrorRange = 0.25
              };
              var generator = new Generator(options);
              var generated = generator.Generate();

              var optimizer = new LcFunctionLinearOptimizer(pl);
              optimizer.Optimize(generated);
              Console.WriteLine(pl.ToShow(generated));
        }
コード例 #6
0
        public void GetFilesInGroup_InRoot()
        {
            // Arrange
            var templatesDir = "C:/wwwroot/templates";
            var options = new GeneratorOptions();
            var filesProvider = new Mock<IFilesProvider>();
            filesProvider
                .Setup(p => p.EnumerateFilesInDirectory(templatesDir))
                .Returns(new[] { new FakeFileContext("foo.tmpl.html", "foo") });
            var coreGenerator = new CoreGenerator(options, filesProvider.Object);

            // Act
            var files = coreGenerator.GetFilesInGroup(templatesDir, "~");

            // Arrange
            Assert.True(files[0].Name == "foo.tmpl.html");
        }
コード例 #7
0
        public void NormalizeGroups_WithEmptyGroup()
        {
            // Arrange
            var templatesDir = "C:/wwwroot/templates";
            var group = Path.Combine(templatesDir, "somegroup");
            var options = new GeneratorOptions();
            var filesProvider = new Mock<IFilesProvider>();
            filesProvider
                .Setup(p => p.EnumerateDirectories(templatesDir))
                .Returns(new[] { "somegroup" });
            var coreGenerator = new CoreGenerator(options, filesProvider.Object);

            // Act
            var result = coreGenerator.NormalizeGroups(templatesDir, new[] { "" });

            // Arrange
            Assert.True(result.Length == 2);
            Assert.True(result[0] == "~");
            Assert.True(result[1] == "somegroup");
        }
コード例 #8
0
        public void TestNonLinearOptimizeLppl()
        {
            var lppl = new Lppl();

              var options = new GeneratorOptions
              {
            Function = lppl.Evaluate,
            TimeRangeMax = 0.9,
            ErrorRange = 0.1
              };
              var generator = new Generator(options);
              var generated = generator.Generate();

              lppl.M += 0.0;
              lppl.Omega -= 0.5;
              lppl.Tc += 0.0;

              var optimizer = new LcFunctionNonLinearOptimizer(lppl);
              optimizer.Optimize(generated);
              Console.WriteLine(lppl);
              Console.WriteLine(lppl.ToShow(generated));
        }
コード例 #9
0
        public void TestNonLinearOptimizePl()
        {
            var pl = new Pl();
              Console.WriteLine(pl);

              var options = new GeneratorOptions
              {
            Function = pl.Evaluate,
            ErrorRange = 0,//.1,
            TimeRangeMax = 0.8
              };
              var generator = new Generator(options);
              var generated = generator.Generate();

              pl.Tc += 0.5;// 5;
              pl.M += 0.3;

              var optimizer = new LcFunctionNonLinearOptimizer(pl);
              optimizer.Optimize(generated);
              Console.WriteLine(pl);
              Console.WriteLine(pl.ToShow(generated));
        }
コード例 #10
0
        /// <summary>
        /// Generates the password.
        /// </summary>
        /// <returns></returns>
        private static string GeneratePassword(int passwordLength,
                                               GeneratorOptions option)
        {
            if (passwordLength < 0) return null;

            var passwordChars = GetCharacters(option);

            if (string.IsNullOrEmpty(passwordChars)) return null;

            var password = new char[passwordLength];

            var random = GetRandom();

            for (int i = 0; i < passwordLength; i++)
            {
                var index = random.Next(passwordChars.Length);
                var passwordChar = passwordChars[index];

                password[i] = passwordChar;
            }

            return new string(password);
        }
コード例 #11
0
 public RustMemorySizeInfoTableGenerator(GeneratorOptions generatorOptions)
 {
     idConverter           = RustIdentifierConverter.Create();
     this.generatorOptions = generatorOptions;
 }
コード例 #12
0
 /// <summary>
 /// Gets the characters selected by the option
 /// </summary>
 /// <returns></returns>
 private static string GetCharacters(GeneratorOptions option)
 {
     switch (option)
     {
         case GeneratorOptions.Alpha:
             return PASSWORD_CHARS_Alpha;
         case GeneratorOptions.Numeric:
             return PASSWORD_CHARS_NUMERIC;
         case GeneratorOptions.AlphaNumeric:
             return PASSWORD_CHARS_Alpha + PASSWORD_CHARS_NUMERIC;
         case GeneratorOptions.AlphaNumericSpecial:
             return PASSWORD_CHARS_Alpha + PASSWORD_CHARS_NUMERIC +
                    PASSWORD_CHARS_SPECIAL;
         default:
             break;
     }
     return string.Empty;
 }
コード例 #13
0
 public EntityClassTemplate(Entity entity, GeneratorOptions options) : base(options)
 {
     _entity = entity;
 }
コード例 #14
0
        /// <summary>
        /// Validate the policy first and return a sanitized/valid set of options for use with Generate.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static SanitizedGeneratorOptions ValidateOptions(GeneratorOptions options)
        {
            // Enforce some acceptable defaults:
            int minLength = options.MinLength ?? 8;
            int maxLength = options.MaxLength ?? 24;
            int minWordCount = options.MinWordCount ?? 3;
            bool requireUppercase = options.RequireUppercase ?? true;
            bool uppercaseOnlyFirstLetters = options.UppercaseOnlyFirstLetters ?? false;
            bool requireNumber = options.RequireNumber ?? true;
            bool appendNumberToEndOnly = options.AppendNumberToEndOnly ?? false;

            // Limit the ranges:
            if (minLength < 1) minLength = 1;
            if (maxLength < 1) maxLength = 1;
            if (minWordCount < 1) minWordCount = 1;

            // Check sanity of the policy:
            if (minLength > maxLength)
                throw new ArgumentOutOfRangeException("MinLength cannot be greater than MaxLength");

            // Each word is at least 2 chars (avg):
            int trueMinLength = (minWordCount * 2) + (requireNumber ? 1 : 0);
            if (maxLength < trueMinLength)
                throw new ArgumentOutOfRangeException("MaxLength is not large enough to accommodate the minimum number of words required");

            char[] addThese = options.RequiredSpecialChars;
            // TODO(jsd): I'd feel better with a character whitelist as opposed to this blacklist.
            char[] removeThese = options.RemoveTheseChars;

            if (removeThese != null)
            {
                // Can't exclude alpha chars:
                if (removeThese.Any(c => Char.IsLetter(c)))
                    throw new ArgumentOutOfRangeException("RemoveTheseChars cannot contain alpha chars");

                // If we require a numeric char yet we exclude numeric chars, that does not make sense:
                if (requireNumber && removeThese.Any(c => Char.IsDigit(c)))
                    throw new ArgumentOutOfRangeException("RequireNumber is true yet RemoveTheseChars contains numeric chars");

                // Make sure the char sets don't conflict:
                if (addThese != null)
                {
                    if (addThese.Intersect(removeThese).Any())
                        throw new ArgumentOutOfRangeException("Set of chars to add and set of chars to remove cannot overlap");
                    if (removeThese.Intersect(addThese).Any())
                        throw new ArgumentOutOfRangeException("Set of chars to add and set of chars to remove cannot overlap");
                }
            }

            return new SanitizedGeneratorOptions(
                minLength,
                maxLength,
                minWordCount,
                requireUppercase,
                uppercaseOnlyFirstLetters,
                requireNumber,
                appendNumberToEndOnly,
                addThese,
                removeThese
            );
        }
コード例 #15
0
 public QueryExtensionTemplate(Entity entity, GeneratorOptions options) : base(options)
 {
     this._entity = entity;
 }
コード例 #16
0
 public ModelClassTemplate(Model model, GeneratorOptions options) : base(options)
 {
     _model = model;
 }
コード例 #17
0
 protected BaseTemplateWriter(GeneratorOptions options)
 {
     this.Options = options;
 }
コード例 #18
0
 public static LanguageAbstractFactory Create(GeneratorOptions options)
 {
     return(new CSharpAbstractFactory(options));
 }
コード例 #19
0
 public Generator(CSharpCompiler re, TextWriter codeWriter, TextWriter snippetWriter, GeneratorOptions options)
 {
     _re = re;
     MainCode = codeWriter;
     SnippetsCode = snippetWriter;
     _options = options;
 }
コード例 #20
0
        private string genAssemblyInfo(ScriptContext context, Script script, GeneratorOptions options)
        {
            if ((options & GeneratorOptions.CreateMain) == 0)
                return string.Empty;
            var d = new Dictionary<string, string>()
                        {
                            {"[assembly: System.Reflection.AssemblyTitle('{}')]", script.VersionInfo.Title},
                            {"[assembly: System.Reflection.AssemblyDescription('{}')]", script.VersionInfo.Value},
                            {"[assembly: System.Reflection.AssemblyCompany('{}')]", script.VersionInfo.Company},
                            {"[assembly: System.Reflection.AssemblyProduct('{}')]", script.VersionInfo.Product},
                            {"[assembly: System.Reflection.AssemblyCopyright('{}')]", script.VersionInfo.Copyright},
                            {"[assembly: System.Reflection.AssemblyVersion('{}')]", script.VersionInfo.Version},
                            {"[assembly: System.Reflection.AssemblyFileVersion('{}')]", script.VersionInfo.Version}
                        };
            StringBuilder sb=new StringBuilder();

            foreach (var pair in d)
            {
                var tr = context.TransformStr(pair.Value??string.Empty, script.VersionInfo.Transform | TransformRules.Trim ).Replace("\"","\"\"");
                if (!string.IsNullOrEmpty(tr))
                    sb.AppendLine(pair.Key.Replace("'{}'", "@\"" + tr + "\""));
            }

            if (sb.Length==0)
                return string.Empty;

            ScriptContext sv=new ScriptContext();
            sv["guid"] = ToValidName(Guid.NewGuid().ToString());
            sv["code"] = sb.ToString();

            string s = @"#region -- Assembly attributes --
            ${code}
            // C# compiler bug may treat assembly attributes as applying to namespace
            class C${guid} {}
            #endregion";
            return sv.ExpandStr(s);
        }
コード例 #21
0
ファイル: TOCWriter.cs プロジェクト: rajdotnet/aws-sdk-net
 public TOCWriter(GeneratorOptions options, IList<GenerationManifest> manifests)
     : base(options)
 {
     _manifests = manifests;
 }
コード例 #22
0
        private bool GenerateProtos()
        {
            DescriptorProtoFile.Descriptor.ToString();
            var options = new GeneratorOptions
            {
                InputFiles = new List<string>(new[] { GetDescriptor() }),
                OutputDirectory = Output
            };

            IList<string> validationFailures;
            if (!options.TryValidate(out validationFailures))
            {
                var exception = new InvalidOptionsException(validationFailures);
                Log.LogError(string.Format("Invalid options: " + exception.Message));
                return false;
            }

            var generator = Generator.CreateGenerator(options);
            generator.Generate();

            return true;
        }
コード例 #23
0
ファイル: PuzzleGrid.cs プロジェクト: Farouq/semclone
		/// <summary>Generates a new puzzle and sets it to be the current puzzle in the grid.</summary>
		/// <param name="options">Options to use for the puzzle generation.</param>
		/// <remarks>Resets the undo states for the grid.</remarks>
		public void GenerateNewPuzzle(GeneratorOptions options)
		{
			LoadNewPuzzle(_puzzleGenerator.Generate(options));
		}
コード例 #24
0
 /// <summary>
 /// Generates a random password.
 /// </summary>
 /// <returns>Randomly generated password.</returns>
 public static string Generate(int passwordLength,
                               GeneratorOptions option)
 {
     return GeneratePassword(passwordLength, option);
 }
コード例 #25
0
 public RustEncoderGenerator(GeneratorOptions generatorOptions)
 {
     idConverter           = RustIdentifierConverter.Create();
     this.generatorOptions = generatorOptions;
     enumGenerator         = new RustEnumsGenerator(generatorOptions);
 }
コード例 #26
0
        public void Generate(ScriptContext context, TextWriter codeStream, Script script, GeneratorOptions options)
        {
            Compiler.AddHeaders("using XS = " + typeof(Script).Namespace + ";");

            ScriptContext sv = new ScriptContext();
            sv["main"]= ((options & GeneratorOptions.CreateMain) != 0) ? genMain() : string.Empty;
            sv["assembly"] = genAssemblyInfo(context, script, options);
            sv["namespace"] = Namespace;
            sv["class"] = Class;
            sv["src"] = script.Location;
            sv["date"] = DateTime.Now.ToString();
            sv["version"] = context.CoreVersion.ToString();
            sv["script"] = Compiler.GetTypeName(script.GetType());
            sv["callIsolation"] = Compiler.GetTypeName(typeof (CallIsolation));
            sv["iscriptaction"] = Compiler.GetTypeName(typeof (IScriptAction));
            sv["usings"] = Compiler.GenerateFileHeader(true,false,false);
            sv["headers"] = Compiler.GenerateFileHeader(false,true,false);
            sv["context"] = Compiler.GetTypeName(context.GetType());
            using (StringWriter swCode = new StringWriter())
            using (StringWriter swSnippets = new StringWriter())
            using (new ScriptContextScope(context))
            {
                Generator c = new Generator(Compiler, swCode, swSnippets, options);
                c.GenerateObjectCode(script, "_script", 3);
                sv["snippets-code"] = swSnippets.ToString();
                sv["script-code"] = swCode.ToString();
            }
            using (MemoryStream ms = AppDomainLoader.TryLoadResourceStream("XSharper.Embedded.Source.SourceTemplate"))
            using (var sr = new StreamReader(ms))
            codeStream.Write(sv.ExpandStr(sr.ReadToEnd()));
        }
コード例 #27
0
        private static void Generate(string projectFolder, string configPath)
        {
            // get config

            configPath = !string.IsNullOrEmpty(configPath)
                ? Path.Combine(projectFolder, configPath)
                : Path.Combine(projectFolder, "tgconfig.json");

            TgConfig config = _configProvider.GetConfig(configPath, projectFolder);

            // register assembly resolver

            _assemblyResolver.Directories = config.ExternalAssemblyPaths;
            _assemblyResolver.Register();

            IEnumerable <Assembly> assemblies = GetAssemblies(config.GetAssemblies()).ToArray();

            // create generator

            GeneratorOptions generatorOptions = _generatorOptionsProvider.GetGeneratorOptions(config, assemblies, projectFolder);

            generatorOptions.BaseOutputDirectory = Path.Combine(projectFolder, config.OutputPath);
            var generator = new Generator(generatorOptions, _logger);

            // generate

            if (config.ClearOutputDirectory == true)
            {
                _fileSystem.ClearDirectory(generatorOptions.BaseOutputDirectory);
            }

            IEnumerable <string> generatedFiles = Enumerable.Empty <string>();

            if (!config.GenerationSpecs.Any() || config.GenerateFromAssemblies == true)
            {
                generatedFiles = generator.Generate(assemblies);
            }

            if (config.GenerationSpecs.Any())
            {
                var typeResolver = new TypeResolver(_logger, _fileSystem, projectFolder, assemblies);

                generatedFiles = config.GenerationSpecs
                                 .Select(name => typeResolver.Resolve(name, "GenerationSpec"))
                                 .Where(t => t != null)
                                 .Select(t => (GenerationSpec)Activator.CreateInstance(t))
                                 .Aggregate(generatedFiles, (acc, spec) => acc.Concat(generator.Generate(spec)));
            }

            _logger.Log("");
            _logger.Log(generatedFiles.Select(x => $"Generated {x}").ToArray());
            _logger.Log("");

            if (config.AddFilesToProject ?? TgConfig.DefaultAddFilesToProject)
            {
                AddFilesToProject(projectFolder, generatedFiles);
            }

            // unregister assembly resolver

            _assemblyResolver.Unregister();
        }
コード例 #28
0
        public CSharpEnumsGenerator(GeneratorOptions generatorOptions)
        {
            idConverter = CSharpIdentifierConverter.Create();
            docWriter   = new CSharpDocCommentWriter(idConverter);

            toFullFileInfo = new Dictionary <TypeId, FullEnumFileInfo>();
            toFullFileInfo.Add(TypeIds.Code, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.Code) + ".g.cs"), CSharpConstants.IcedNamespace));
            toFullFileInfo.Add(TypeIds.CodeSize, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.CodeSize) + ".g.cs"), CSharpConstants.IcedNamespace));
            toFullFileInfo.Add(TypeIds.ConditionCode, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.ConditionCode) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.InstructionInfoDefine));
            toFullFileInfo.Add(TypeIds.CpuidFeature, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.CpuidFeature) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.InstructionInfoDefine));
            toFullFileInfo.Add(TypeIds.CpuidFeatureInternal, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), nameof(TypeIds.CpuidFeatureInternal) + ".g.cs"), CSharpConstants.InstructionInfoNamespace, CSharpConstants.InstructionInfoDefine));
            toFullFileInfo.Add(TypeIds.DecoderOptions, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.DecoderOptions) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.DecoderDefine, baseType: "uint"));
            toFullFileInfo.Add(TypeIds.EvexOpCodeHandlerKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.DecoderNamespace), nameof(TypeIds.EvexOpCodeHandlerKind) + ".g.cs"), CSharpConstants.DecoderNamespace, CSharpConstants.DecoderDefine, baseType: "byte"));
            toFullFileInfo.Add(TypeIds.HandlerFlags, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.DecoderNamespace), nameof(TypeIds.HandlerFlags) + ".g.cs"), CSharpConstants.DecoderNamespace, CSharpConstants.DecoderDefine, baseType: "uint"));
            toFullFileInfo.Add(TypeIds.LegacyHandlerFlags, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.DecoderNamespace), nameof(TypeIds.LegacyHandlerFlags) + ".g.cs"), CSharpConstants.DecoderNamespace, CSharpConstants.DecoderDefine, baseType: "uint"));
            toFullFileInfo.Add(TypeIds.MemorySize, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.MemorySize) + ".g.cs"), CSharpConstants.IcedNamespace));
            toFullFileInfo.Add(TypeIds.OpCodeHandlerKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.DecoderNamespace), nameof(TypeIds.OpCodeHandlerKind) + ".g.cs"), CSharpConstants.DecoderNamespace, CSharpConstants.DecoderDefine, baseType: "byte"));
            toFullFileInfo.Add(TypeIds.PseudoOpsKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.FormatterNamespace), nameof(TypeIds.PseudoOpsKind) + ".g.cs"), CSharpConstants.FormatterNamespace, CSharpConstants.AnyFormatterDefine));
            toFullFileInfo.Add(TypeIds.Register, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.Register) + ".g.cs"), CSharpConstants.IcedNamespace));
            toFullFileInfo.Add(TypeIds.SerializedDataKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.DecoderNamespace), nameof(TypeIds.SerializedDataKind) + ".g.cs"), CSharpConstants.DecoderNamespace, CSharpConstants.DecoderDefine, baseType: "byte"));
            toFullFileInfo.Add(TypeIds.TupleType, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.TupleType) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.DecoderOrEncoderDefine));
            toFullFileInfo.Add(TypeIds.VexOpCodeHandlerKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.DecoderNamespace), nameof(TypeIds.VexOpCodeHandlerKind) + ".g.cs"), CSharpConstants.DecoderNamespace, CSharpConstants.DecoderDefine, baseType: "byte"));
            toFullFileInfo.Add(TypeIds.Mnemonic, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.Mnemonic) + ".g.cs"), CSharpConstants.IcedNamespace));
            toFullFileInfo.Add(TypeIds.GasCtorKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.GasFormatterNamespace), "CtorKind.g.cs"), CSharpConstants.GasFormatterNamespace, CSharpConstants.GasFormatterDefine));
            toFullFileInfo.Add(TypeIds.IntelCtorKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IntelFormatterNamespace), "CtorKind.g.cs"), CSharpConstants.IntelFormatterNamespace, CSharpConstants.IntelFormatterDefine));
            toFullFileInfo.Add(TypeIds.MasmCtorKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.MasmFormatterNamespace), "CtorKind.g.cs"), CSharpConstants.MasmFormatterNamespace, CSharpConstants.MasmFormatterDefine));
            toFullFileInfo.Add(TypeIds.NasmCtorKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.NasmFormatterNamespace), "CtorKind.g.cs"), CSharpConstants.NasmFormatterNamespace, CSharpConstants.NasmFormatterDefine));
            toFullFileInfo.Add(TypeIds.GasSizeOverride, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.GasFormatterNamespace), "SizeOverride.g.cs"), CSharpConstants.GasFormatterNamespace, CSharpConstants.GasFormatterDefine));
            toFullFileInfo.Add(TypeIds.GasInstrOpInfoFlags, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.GasFormatterNamespace), "InstrOpInfoFlags.g.cs"), CSharpConstants.GasFormatterNamespace, CSharpConstants.GasFormatterDefine, "ushort"));
            toFullFileInfo.Add(TypeIds.IntelSizeOverride, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IntelFormatterNamespace), "SizeOverride.g.cs"), CSharpConstants.IntelFormatterNamespace, CSharpConstants.IntelFormatterDefine));
            toFullFileInfo.Add(TypeIds.IntelBranchSizeInfo, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IntelFormatterNamespace), "BranchSizeInfo.g.cs"), CSharpConstants.IntelFormatterNamespace, CSharpConstants.IntelFormatterDefine));
            toFullFileInfo.Add(TypeIds.IntelInstrOpInfoFlags, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IntelFormatterNamespace), "InstrOpInfoFlags.g.cs"), CSharpConstants.IntelFormatterNamespace, CSharpConstants.IntelFormatterDefine, "ushort"));
            toFullFileInfo.Add(TypeIds.MasmInstrOpInfoFlags, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.MasmFormatterNamespace), "InstrOpInfoFlags.g.cs"), CSharpConstants.MasmFormatterNamespace, CSharpConstants.MasmFormatterDefine, "ushort"));
            toFullFileInfo.Add(TypeIds.NasmSignExtendInfo, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.NasmFormatterNamespace), "SignExtendInfo.g.cs"), CSharpConstants.NasmFormatterNamespace, CSharpConstants.NasmFormatterDefine));
            toFullFileInfo.Add(TypeIds.NasmSizeOverride, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.NasmFormatterNamespace), "SizeOverride.g.cs"), CSharpConstants.NasmFormatterNamespace, CSharpConstants.NasmFormatterDefine));
            toFullFileInfo.Add(TypeIds.NasmBranchSizeInfo, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.NasmFormatterNamespace), "BranchSizeInfo.g.cs"), CSharpConstants.NasmFormatterNamespace, CSharpConstants.NasmFormatterDefine));
            toFullFileInfo.Add(TypeIds.NasmInstrOpInfoFlags, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.NasmFormatterNamespace), "InstrOpInfoFlags.g.cs"), CSharpConstants.NasmFormatterNamespace, CSharpConstants.NasmFormatterDefine, "uint"));
            toFullFileInfo.Add(TypeIds.RoundingControl, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.RoundingControl) + ".g.cs"), CSharpConstants.IcedNamespace));
            toFullFileInfo.Add(TypeIds.OpKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.OpKind) + ".g.cs"), CSharpConstants.IcedNamespace));
            toFullFileInfo.Add(TypeIds.VectorLength, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.VectorLength) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.DecoderOrEncoderDefine));
            toFullFileInfo.Add(TypeIds.MandatoryPrefixByte, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.MandatoryPrefixByte) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.DecoderOrEncoderDefine, "uint"));            // 'uint' not 'byte' since it gets zx to uint when OR'ing values
            toFullFileInfo.Add(TypeIds.EncodingKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.EncodingKind) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.DecoderOrEncoderOrInstrInfoDefine));
            toFullFileInfo.Add(TypeIds.FlowControl, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.FlowControl) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.InstructionInfoDefine));
            toFullFileInfo.Add(TypeIds.OpCodeOperandKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.OpCodeOperandKind) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.EncoderDefine));
            toFullFileInfo.Add(TypeIds.RflagsBits, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.RflagsBits) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.InstructionInfoDefine));
            toFullFileInfo.Add(TypeIds.OpAccess, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.OpAccess) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.InstructionInfoDefine));
            toFullFileInfo.Add(TypeIds.MandatoryPrefix, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.MandatoryPrefix) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.EncoderDefine));
            toFullFileInfo.Add(TypeIds.OpCodeTableKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.OpCodeTableKind) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.EncoderDefine));
            toFullFileInfo.Add(TypeIds.FormatterTextKind, new FullEnumFileInfo(Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), nameof(TypeIds.FormatterTextKind) + ".g.cs"), CSharpConstants.IcedNamespace, CSharpConstants.AnyFormatterDefine));

            toPartialFileInfo = new Dictionary <TypeId, PartialEnumFileInfo>();
            toPartialFileInfo.Add(TypeIds.Instruction_MemoryFlags, new PartialEnumFileInfo("MemoryFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "Instruction.cs"), "ushort"));
            toPartialFileInfo.Add(TypeIds.Instruction_OpKindFlags, new PartialEnumFileInfo("OpKindFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "Instruction.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.Instruction_CodeFlags, new PartialEnumFileInfo("CodeFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "Instruction.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.OpSize, new PartialEnumFileInfo("OpSize", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "Decoder.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.StateFlags, new PartialEnumFileInfo("StateFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "Decoder.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.CodeInfo, new PartialEnumFileInfo("CodeInfo", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), null));
            toPartialFileInfo.Add(TypeIds.RflagsInfo, new PartialEnumFileInfo("RflagsInfo", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), null));
            toPartialFileInfo.Add(TypeIds.OpInfo0, new PartialEnumFileInfo("OpInfo0", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), null));
            toPartialFileInfo.Add(TypeIds.OpInfo1, new PartialEnumFileInfo("OpInfo1", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), null));
            toPartialFileInfo.Add(TypeIds.OpInfo2, new PartialEnumFileInfo("OpInfo2", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), null));
            toPartialFileInfo.Add(TypeIds.OpInfo3, new PartialEnumFileInfo("OpInfo3", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), null));
            toPartialFileInfo.Add(TypeIds.OpInfo4, new PartialEnumFileInfo("OpInfo4", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), null));
            toPartialFileInfo.Add(TypeIds.InfoFlags1, new PartialEnumFileInfo("InfoFlags1", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.InfoFlags2, new PartialEnumFileInfo("InfoFlags2", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.InstructionInfoNamespace), "InfoHandlerFlags.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.MemorySizeFlags, new PartialEnumFileInfo("MemorySizeFlags", Path.Combine(generatorOptions.CSharpTestsDir, "Intel", "InstructionInfoTests", "InstructionInfoConstants.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.RegisterFlags, new PartialEnumFileInfo("RegisterFlags", Path.Combine(generatorOptions.CSharpTestsDir, "Intel", "InstructionInfoTests", "InstructionInfoConstants.cs"), "uint"));

            toPartialFileInfo.Add(TypeIds.LegacyOpCodeTable, new PartialEnumFileInfo("LegacyOpCodeTable", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.VexOpCodeTable, new PartialEnumFileInfo("VexOpCodeTable", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.XopOpCodeTable, new PartialEnumFileInfo("XopOpCodeTable", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.EvexOpCodeTable, new PartialEnumFileInfo("EvexOpCodeTable", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.Encodable, new PartialEnumFileInfo("Encodable", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.OpCodeHandlerFlags, new PartialEnumFileInfo("OpCodeHandlerFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.LegacyOpKind, new PartialEnumFileInfo("LegacyOpKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.VexOpKind, new PartialEnumFileInfo("VexOpKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.XopOpKind, new PartialEnumFileInfo("XopOpKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.EvexOpKind, new PartialEnumFileInfo("EvexOpKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "byte"));

            toPartialFileInfo.Add(TypeIds.FormatterFlowControl, new PartialEnumFileInfo("FormatterFlowControl", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "FormatterUtils.cs"), null));
            toPartialFileInfo.Add(TypeIds.GasInstrOpKind, new PartialEnumFileInfo("InstrOpKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.GasFormatterNamespace), "InstrInfo.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.IntelInstrOpKind, new PartialEnumFileInfo("InstrOpKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IntelFormatterNamespace), "InstrInfo.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.MasmInstrOpKind, new PartialEnumFileInfo("InstrOpKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.MasmFormatterNamespace), "InstrInfo.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.NasmInstrOpKind, new PartialEnumFileInfo("InstrOpKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.NasmFormatterNamespace), "InstrInfo.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.NasmMemorySizeInfo, new PartialEnumFileInfo("MemorySizeInfo", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.NasmFormatterNamespace), "InstrInfo.cs"), null));
            toPartialFileInfo.Add(TypeIds.NasmFarMemorySizeInfo, new PartialEnumFileInfo("FarMemorySizeInfo", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.NasmFormatterNamespace), "InstrInfo.cs"), null));
            toPartialFileInfo.Add(TypeIds.NumberBase, new PartialEnumFileInfo("NumberBase", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "FormatterOptions.cs"), null));
            toPartialFileInfo.Add(TypeIds.MemorySizeOptions, new PartialEnumFileInfo("MemorySizeOptions", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "FormatterOptions.cs"), null));

            toPartialFileInfo.Add(TypeIds.OperandSize, new PartialEnumFileInfo("OperandSize", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.AddressSize, new PartialEnumFileInfo("AddressSize", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.VexVectorLength, new PartialEnumFileInfo("VexVectorLength", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.XopVectorLength, new PartialEnumFileInfo("XopVectorLength", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.EvexVectorLength, new PartialEnumFileInfo("EvexVectorLength", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.DisplSize, new PartialEnumFileInfo("DisplSize", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.ImmSize, new PartialEnumFileInfo("ImmSize", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.EncoderFlags, new PartialEnumFileInfo("EncoderFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.EncFlags1, new PartialEnumFileInfo("EncFlags1", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.LegacyFlags3, new PartialEnumFileInfo("LegacyFlags3", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.VexFlags3, new PartialEnumFileInfo("VexFlags3", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.XopFlags3, new PartialEnumFileInfo("XopFlags3", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.EvexFlags3, new PartialEnumFileInfo("EvexFlags3", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.AllowedPrefixes, new PartialEnumFileInfo("AllowedPrefixes", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), null));
            toPartialFileInfo.Add(TypeIds.LegacyFlags, new PartialEnumFileInfo("LegacyFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.VexFlags, new PartialEnumFileInfo("VexFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.XopFlags, new PartialEnumFileInfo("XopFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.EvexFlags, new PartialEnumFileInfo("EvexFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.D3nowFlags, new PartialEnumFileInfo("D3nowFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.WBit, new PartialEnumFileInfo("WBit", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "Enums.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.LKind, new PartialEnumFileInfo("LKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.EncoderNamespace), "OpCodeFormatter.cs"), "byte"));
            toPartialFileInfo.Add(TypeIds.OpCodeFlags, new PartialEnumFileInfo("Flags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "OpCodeInfo.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.RepPrefixKind, new PartialEnumFileInfo("RepPrefixKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "Instruction.Create.cs"), null));
            toPartialFileInfo.Add(TypeIds.RelocKind, new PartialEnumFileInfo("RelocKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "BlockEncoder.cs"), null));
            toPartialFileInfo.Add(TypeIds.BlockEncoderOptions, new PartialEnumFileInfo("BlockEncoderOptions", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "BlockEncoder.cs"), null));
            toPartialFileInfo.Add(TypeIds.FormatMnemonicOptions, new PartialEnumFileInfo("FormatMnemonicOptions", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "Formatter.cs"), "uint"));
            toPartialFileInfo.Add(TypeIds.PrefixKind, new PartialEnumFileInfo("PrefixKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "FormatterOutput.cs"), null));
            toPartialFileInfo.Add(TypeIds.DecoratorKind, new PartialEnumFileInfo("DecoratorKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "FormatterOutput.cs"), null));
            toPartialFileInfo.Add(TypeIds.NumberKind, new PartialEnumFileInfo("NumberKind", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "FormatterOutput.cs"), null));
            toPartialFileInfo.Add(TypeIds.SymbolFlags, new PartialEnumFileInfo("SymbolFlags", Path.Combine(CSharpConstants.GetDirectory(generatorOptions, CSharpConstants.IcedNamespace), "ISymbolResolver.cs"), "uint"));
        }
コード例 #29
0
        public static void DoVisualBasicTest(string[] expected, CodeCompileUnit compileUnit, GeneratorOptions options = null, bool addOptions = true)
        {
            if (addOptions)
            {
                var tmp = new string[expected.Length + 4];
                tmp[0] = "Option Strict Off";
                tmp[1] = "Option Explicit On";
                tmp[2] = "Option Infer On";
                tmp[3] = "";

                for (int i = 0; i < expected.Length; i++)
                {
                    tmp[i + 4] = expected[i];
                }

                expected = tmp;
            }
            DoTest(expected, compileUnit, Language.VisualBasic, options);
        }
コード例 #30
0
 protected BaseTemplateWriter(GeneratorOptions options, string outputFolder)
 {
     Options      = options;
     OutputFolder = outputFolder;
 }
コード例 #31
0
        public void Generate(ScriptContext context, TextWriter codeStream, Script script, GeneratorOptions options)
        {
            Compiler.AddHeaders("using XS = " + typeof(Script).Namespace + ";");

            ScriptContext sv = new ScriptContext();

            sv["main"]          = ((options & GeneratorOptions.CreateMain) != 0) ? genMain() : string.Empty;
            sv["assembly"]      = genAssemblyInfo(context, script, options);
            sv["namespace"]     = Namespace;
            sv["class"]         = Class;
            sv["src"]           = script.Location;
            sv["date"]          = DateTime.Now.ToString();
            sv["version"]       = context.CoreVersion.ToString();
            sv["script"]        = Compiler.GetTypeName(script.GetType());
            sv["callIsolation"] = Compiler.GetTypeName(typeof(CallIsolation));
            sv["iscriptaction"] = Compiler.GetTypeName(typeof(IScriptAction));
            sv["usings"]        = Compiler.GenerateFileHeader(true, false, false);
            sv["headers"]       = Compiler.GenerateFileHeader(false, true, false);
            sv["context"]       = Compiler.GetTypeName(context.GetType());
            using (StringWriter swCode = new StringWriter())
                using (StringWriter swSnippets = new StringWriter())
                    using (new ScriptContextScope(context))
                    {
                        Generator c = new Generator(Compiler, swCode, swSnippets, options);
                        c.GenerateObjectCode(script, "_script", 3);
                        sv["snippets-code"] = swSnippets.ToString();
                        sv["script-code"]   = swCode.ToString();
                    }
            using (MemoryStream ms = AppDomainLoader.TryLoadResourceStream("XSharper.Embedded.Source.SourceTemplate"))
                using (var sr = new StreamReader(ms))
                    codeStream.Write(sv.ExpandStr(sr.ReadToEnd()));
        }
コード例 #32
0
 public DataContextTemplate(EntityContext entityContext, GeneratorOptions options) : base(options)
 {
     _entityContext = entityContext;
 }
コード例 #33
0
 public EntityScriptTemplate(ILoggerFactory loggerFactory, GeneratorOptions generatorOptions, TemplateOptions templateOptions)
     : base(loggerFactory, generatorOptions, templateOptions)
 {
 }
コード例 #34
0
 public CSharpTableGen(GeneratorOptions generatorOptions)
 {
     idConverter           = CSharpIdentifierConverter.Create();
     this.generatorOptions = generatorOptions;
 }
コード例 #35
0
        public void NormalizeGroups_WithNormalGroups(string concatGroups)
        {
            // Arrange
            var groups = concatGroups.Split(' ');
            var templatesDir = "C:/wwwroot/templates";
            var options = new GeneratorOptions();
            var filesProvider = new Mock<IFilesProvider>();
            var coreGenerator = new CoreGenerator(options, filesProvider.Object);

            // Act
            var result = coreGenerator.NormalizeGroups(templatesDir, groups);

            // Arrange
            Assert.Same(groups, result);
        }
コード例 #36
0
 /// <summary>Generates a new puzzle and sets it to be the current puzzle in the grid.</summary>
 /// <param name="options">Options to use for the puzzle generation.</param>
 /// <remarks>Resets the undo states for the grid.</remarks>
 public void GenerateNewPuzzle(GeneratorOptions options)
 {
     LoadNewPuzzle(_puzzleGenerator.Generate(options));
 }
コード例 #37
0
        public void GenerateCheckNameCase()
        {
            var generatorOptions = new GeneratorOptions();
            var databaseModel    = new DatabaseModel
            {
                DatabaseName  = "TestDatabase",
                DefaultSchema = "dbo"
            };
            var testTable = new DatabaseTable
            {
                Database = databaseModel,
                Name     = "aammstest",
                Schema   = "dbo"
            };

            databaseModel.Tables.Add(testTable);

            var identifierColumn = new DatabaseColumn
            {
                Table      = testTable,
                Name       = "Id",
                IsNullable = false,
                StoreType  = "int"
            };

            testTable.Columns.Add(identifierColumn);

            var nameColumn = new DatabaseColumn
            {
                Table      = testTable,
                Name       = "Name",
                IsNullable = true,
                StoreType  = "varchar(50)"
            };

            testTable.Columns.Add(nameColumn);
            var generator = new ModelGenerator(NullLoggerFactory.Instance);

            var result = generator.Generate(generatorOptions, databaseModel);

            result.ContextClass.Should().Be("TestDatabaseContext");
            result.ContextNamespace.Should().Be("TestDatabase.Data");
            result.Entities.Count.Should().Be(1);

            var firstEntity = result.Entities[0];

            firstEntity.TableName.Should().Be("aammstest");
            firstEntity.TableSchema.Should().Be("dbo");
            firstEntity.EntityClass.Should().Be("Aammstest");
            firstEntity.EntityNamespace.Should().Be("TestDatabase.Data.Entities");
            firstEntity.MappingClass.Should().Be("AammstestMap");
            firstEntity.MappingNamespace.Should().Be("TestDatabase.Data.Mapping");

            firstEntity.Properties.Count.Should().Be(2);

            var identifierProperty = firstEntity.Properties.ByColumn("Id");

            identifierProperty.Should().NotBeNull();
            identifierProperty.PropertyName.Should().Be("Id");

            var nameProperty = firstEntity.Properties.ByColumn("Name");

            nameProperty.Should().NotBeNull();
            nameProperty.PropertyName.Should().Be("Name");
        }
コード例 #38
0
 protected BaseTemplateWriter(GeneratorOptions options)
 {
     this.Options = options;
 }
コード例 #39
0
        public void GenerateWithPrefixedSchemaName()
        {
            var generatorOptions = new GeneratorOptions();

            generatorOptions.Data.Entity.PrefixWithSchemaName = true;
            var databaseModel = new DatabaseModel
            {
                DatabaseName  = "TestDatabase",
                DefaultSchema = "dbo"
            };
            var testTableDbo = new DatabaseTable
            {
                Database = databaseModel,
                Name     = "TestTable",
                Schema   = "dbo"
            };
            var testTableTst = new DatabaseTable
            {
                Database = databaseModel,
                Name     = "TestTable",
                Schema   = "tst"
            };

            databaseModel.Tables.Add(testTableDbo);
            databaseModel.Tables.Add(testTableTst);

            var identifierColumnDbo = new DatabaseColumn
            {
                Table      = testTableDbo,
                Name       = "Id",
                IsNullable = false,
                StoreType  = "int"
            };
            var identifierColumnTst = new DatabaseColumn
            {
                Table      = testTableTst,
                Name       = "Id",
                IsNullable = false,
                StoreType  = "int"
            };

            testTableDbo.Columns.Add(identifierColumnDbo);
            testTableDbo.Columns.Add(identifierColumnTst);

            var nameColumnDbo = new DatabaseColumn
            {
                Table      = testTableDbo,
                Name       = "Name",
                IsNullable = true,
                StoreType  = "varchar(50)"
            };
            var nameColumnTst = new DatabaseColumn
            {
                Table      = testTableTst,
                Name       = "Name",
                IsNullable = true,
                StoreType  = "varchar(50)"
            };

            testTableDbo.Columns.Add(nameColumnDbo);
            testTableDbo.Columns.Add(nameColumnTst);

            var generator = new ModelGenerator(NullLoggerFactory.Instance);

            var result = generator.Generate(generatorOptions, databaseModel);

            result.ContextClass.Should().Be("TestDatabaseContext");
            result.ContextNamespace.Should().Be("TestDatabase.Data");
            result.Entities.Count.Should().Be(2);

            var firstEntity = result.Entities[0];

            firstEntity.TableName.Should().Be("TestTable");
            firstEntity.TableSchema.Should().Be("dbo");
            firstEntity.EntityClass.Should().Be("DboTestTable");
            firstEntity.EntityNamespace.Should().Be("TestDatabase.Data.Entities");
            firstEntity.MappingClass.Should().Be("DboTestTableMap");
            firstEntity.MappingNamespace.Should().Be("TestDatabase.Data.Mapping");

            var secondEntity = result.Entities[1];

            secondEntity.TableName.Should().Be("TestTable");
            secondEntity.TableSchema.Should().Be("tst");
            secondEntity.EntityClass.Should().Be("TstTestTable");
            secondEntity.EntityNamespace.Should().Be("TestDatabase.Data.Entities");
            secondEntity.MappingClass.Should().Be("TstTestTableMap");
            secondEntity.MappingNamespace.Should().Be("TestDatabase.Data.Mapping");
        }
コード例 #40
0
 public static void DoCSharpTest(string[] expected, CodeCompileUnit compileUnit, GeneratorOptions options = null)
 {
     DoTest(expected, compileUnit, Language.CSharp, options);
 }
コード例 #41
0
        public void GenerateModelsCheckNames()
        {
            var generatorOptions = new GeneratorOptions();

            generatorOptions.Model.Read.Generate      = true;
            generatorOptions.Model.Create.Generate    = true;
            generatorOptions.Model.Update.Generate    = true;
            generatorOptions.Model.Validator.Generate = true;
            generatorOptions.Model.Mapper.Generate    = true;

            var databaseModel = new DatabaseModel
            {
                DatabaseName  = "TestDatabase",
                DefaultSchema = "dbo"
            };
            var testTable = new DatabaseTable
            {
                Database = databaseModel,
                Name     = "TestTable",
                Schema   = "dbo"
            };

            databaseModel.Tables.Add(testTable);

            var identifierColumn = new DatabaseColumn
            {
                Table      = testTable,
                Name       = "Id",
                IsNullable = false,
                StoreType  = "int"
            };

            testTable.Columns.Add(identifierColumn);

            var nameColumn = new DatabaseColumn
            {
                Table      = testTable,
                Name       = "Name",
                IsNullable = true,
                StoreType  = "varchar(50)"
            };

            testTable.Columns.Add(nameColumn);
            var generator = new ModelGenerator(NullLoggerFactory.Instance);

            var result = generator.Generate(generatorOptions, databaseModel);

            result.ContextClass.Should().Be("TestDatabaseContext");
            result.ContextNamespace.Should().Be("TestDatabase.Data");
            result.Entities.Count.Should().Be(1);

            var firstEntity = result.Entities[0];

            firstEntity.TableName.Should().Be("TestTable");
            firstEntity.TableSchema.Should().Be("dbo");
            firstEntity.EntityClass.Should().Be("TestTable");
            firstEntity.EntityNamespace.Should().Be("TestDatabase.Data.Entities");
            firstEntity.MappingClass.Should().Be("TestTableMap");
            firstEntity.MappingNamespace.Should().Be("TestDatabase.Data.Mapping");
            firstEntity.MapperClass.Should().Be("TestTableProfile");
            firstEntity.MapperNamespace.Should().Be("TestDatabase.Domain.Mapping");

            firstEntity.Properties.Count.Should().Be(2);
            firstEntity.Models.Count.Should().Be(3);

            var firstModel = firstEntity.Models[0];

            firstModel.ModelClass.Should().StartWith("TestTable");
            firstModel.ModelClass.Should().EndWith("Model");
            firstModel.ModelNamespace.Should().Be("TestDatabase.Domain.Models");
            firstModel.ValidatorClass.Should().StartWith("TestTable");
            firstModel.ValidatorClass.Should().EndWith("Validator");
            firstModel.ValidatorNamespace.Should().Be("TestDatabase.Domain.Validation");
        }
コード例 #42
0
 public CSharpD3nowCodeValuesTableGenerator(GeneratorOptions generatorOptions)
 {
     idConverter           = CSharpIdentifierConverter.Create();
     this.generatorOptions = generatorOptions;
 }
コード例 #43
0
 public RustFormatterTableGenerator(GeneratorOptions generatorOptions) =>
 this.generatorOptions = generatorOptions;
コード例 #44
0
 public Generator(CSharpCompiler re, TextWriter codeWriter, TextWriter snippetWriter, GeneratorOptions options)
 {
     _re          = re;
     MainCode     = codeWriter;
     SnippetsCode = snippetWriter;
     _options     = options;
 }
コード例 #45
0
        private static async Task <int> Main(string[] args)
        {
            string input            = null;
            string output           = null;
            var    version          = false;
            var    showHelp         = false;
            var    generatorOptions = new GeneratorOptions
            {
                LanguageName = "csharp",
                Namespace    = "Generated",
                ClientName   = "ApiClient",
            };

            var options = new OptionSet
            {
                { "i|input=", "The input swagger spec uri", s => input = s },
                { "o|output=", "The output directory for generated code", o => output = o },
                { "n|ns|namespace=", "The namespace for generated code", n => generatorOptions.Namespace = n },
                { "l|language=", "The language to generate code for", l => generatorOptions.LanguageName = l },
                { "c|client-name=", "The name of the generated client", c => generatorOptions.ClientName = c },
                { "version", "Display the version of this program.", v => version = v != null },
                { "h|?|help", "Display this help message.", h => showHelp = h != null },
            };

            List <string> arguments = options.Parse(args);

            if (version)
            {
                string versionString = Assembly.GetEntryAssembly()
                                       .GetCustomAttribute <AssemblyInformationalVersionAttribute>()
                                       .InformationalVersion;
                Console.WriteLine(versionString);
                return(0);
            }

            if (showHelp)
            {
                options.WriteOptionDescriptions(Console.Out);
                return(0);
            }

            if (string.IsNullOrEmpty(input))
            {
                MissingArgument(nameof(input));
            }

            if (string.IsNullOrEmpty(output))
            {
                MissingArgument(nameof(output));
            }

            ILogger logger = new LoggerFactory().AddConsole().CreateLogger("dotnet-swaggergen");

            var(diagnostic, document) = await GetSwaggerDocument(input);

            if (diagnostic.Errors.Any())
            {
                foreach (var error in diagnostic.Errors)
                {
                    Console.Error.WriteLine($"error: In {error.Pointer} '{error.Message}'");
                }

                Console.Error.WriteLine("OpenApi Document parsing resulted in errors. Output may be compromised.");
            }

            var generator            = new ServiceClientModelFactory(generatorOptions);
            ServiceClientModel model = generator.Create(document);

            var             codeFactory = new ServiceClientCodeFactory();
            List <CodeFile> code        = codeFactory.GenerateCode(model, generatorOptions);

            var outputDirectory = new DirectoryInfo(output);

            outputDirectory.Create();

            foreach ((string path, string contents) in code)
            {
                string fullPath = Path.Combine(outputDirectory.FullName, path);
                var    file     = new FileInfo(fullPath);
                file.Directory.Create();
                File.WriteAllText(file.FullName, contents);
            }

            return(0);
        }
コード例 #46
0
 public string GetFilename(GeneratorOptions generatorOptions) =>
 Path.Combine(CSharpConstants.GetDirectory(generatorOptions, @namespace), "InstrInfos.g.cs");
コード例 #47
0
        private static void Generate(string projectFolder, string configPath)
        {
            // get config

            configPath = !string.IsNullOrEmpty(configPath)
                ? Path.Combine(projectFolder, configPath)
                : Path.Combine(projectFolder, "tgconfig.json");

            TgConfig config = _configProvider.GetConfig(configPath, projectFolder);

            LogConfigWarnings(config);

            // register assembly resolver

            _assemblyResolver.Directories = config.ExternalAssemblyPaths;
            _assemblyResolver.Register();

            IEnumerable <Assembly> assemblies = GetAssemblies(config.GetAssemblies()).ToArray();

            // create generator

            GeneratorOptions generatorOptions = _generatorOptionsProvider.GetGeneratorOptions(config, assemblies, projectFolder);

            generatorOptions.BaseOutputDirectory = Path.Combine(projectFolder, config.OutputPath);
            var generator = new Generator(generatorOptions, _logger);

            // generate

            if (config.ClearOutputDirectory == true)
            {
                _fileSystem.ClearDirectory(generatorOptions.BaseOutputDirectory);
            }
            if (config.BuildProject == true)
            {
                _projectBuilder.Build(projectFolder);
            }

            _logger.Log($"Generating files for project \"{projectFolder}\"...", LogLevel.Info);

            var generatedFiles = new List <string>();

            if (!config.GenerationSpecs.Any() || config.GenerateFromAssemblies == true)
            {
                generatedFiles.AddRange(generator.Generate(assemblies));
            }

            if (config.GenerationSpecs.Any())
            {
                var typeResolver = new TypeResolver(_logger, _fileSystem, projectFolder, assemblies);

                IEnumerable <GenerationSpec> generationSpecs = config.GenerationSpecs
                                                               .Select(name => typeResolver.Resolve(name, "GenerationSpec"))
                                                               .Where(t => t != null)
                                                               .Select(t => (GenerationSpec)Activator.CreateInstance(t))
                                                               .ToArray();

                generatedFiles.AddRange(generator.Generate(generationSpecs));
            }

            foreach (string file in generatedFiles)
            {
                _logger.Log($"Generated {file}", LogLevel.Info);
            }

            if (config.AddFilesToProject ?? TgConfig.DefaultAddFilesToProject)
            {
                AddFilesToProject(projectFolder, generatedFiles);
            }

            // unregister assembly resolver

            _assemblyResolver.Unregister();

            _logger.Log($"Files for project \"{projectFolder}\" generated successfully.{Environment.NewLine}", LogLevel.Info);
        }
コード例 #48
0
        public bool Generate(FormulaCodeGeneratorTask genTask)
        {
            var outputFile = InputFile + ".g.cs";

            var env = new Env();

            try
            {
                InstallResult ires;
                var           progName = new ProgramName(InputFile);
                env.Install(InputFile, out ires);
                PrintFlags(genTask, ires.Flags);
                if (!ires.Succeeded)
                {
                    return(false);
                }

                AST <Program> program = null;
                foreach (var touched in ires.Touched)
                {
                    if (touched.Program.Node.Name.Equals(progName))
                    {
                        program = touched.Program;
                        break;
                    }
                }

                if (program == null)
                {
                    PrintError(genTask, InputFile, "Could not find input file");
                    return(false);
                }

                string name;
                string modName     = null;
                var    moduleQuery = new NodePred[] { NodePredFactory.Instance.Star, NodePredFactory.Instance.Module };
                program.FindAll(
                    moduleQuery,
                    (ch, n) =>
                {
                    if (n.TryGetStringAttribute(AttributeKind.Name, out name))
                    {
                        if (modName == null)
                        {
                            modName = name;
                        }
                        else
                        {
                            genTask.Log.LogWarning(
                                string.Empty,
                                string.Empty,
                                string.Empty,
                                InputFile,
                                n.Span.StartLine,
                                n.Span.StartCol,
                                n.Span.EndLine,
                                n.Span.EndCol,
                                "Code will only be generated for module {0}; ignoring module {1}.",
                                modName,
                                name);
                        }
                    }
                });

                if (modName == null)
                {
                    PrintWarning(genTask, InputFile, "Could not find any modules in input file.");
                    return(true);
                }

                try
                {
                    var outInfo = new System.IO.FileInfo(outputFile);
                    if (outInfo.Exists)
                    {
                        outInfo.Delete();
                    }

                    using (var sw = new System.IO.StreamWriter(outputFile))
                    {
                        var opts = new GeneratorOptions(
                            GeneratorOptions.Language.CSharp,
                            IsThreadSafe,
                            IsNewOnly,
                            modName,
                            Namespace);

                        Task <GenerateResult> gres;
                        env.Generate(progName, modName, sw, opts, out gres);
                        gres.Wait();
                        PrintFlags(genTask, InputFile, gres.Result.Flags);
                        if (gres.Result.Succeeded)
                        {
                            genTask.Log.LogMessage("Transformed {0} -> {1}", InputFile, outputFile);
                        }

                        return(gres.Result.Succeeded);
                    }
                }
                catch (Exception e)
                {
                    PrintError(genTask, outputFile, e.Message);
                    return(false);
                }
            }
            catch (Exception e)
            {
                PrintError(genTask, InputFile, e.Message);
                return(false);
            }
        }
コード例 #49
0
 public abstract CodeGenerator CodeGenerator(Type enumType, GeneratorOptions options);
コード例 #50
0
 /// <summary>
 /// Generates a random password with the default length.
 /// </summary>
 /// <returns>Randomly generated password.</returns>
 public static string Generate(GeneratorOptions option)
 {
     return Generate(DEFAULT_PASSWORD_LENGTH, option);
 }
コード例 #51
0
 public CSharpAbstractFactory(GeneratorOptions options)
 {
     _options = options;
 }
コード例 #52
0
 public override CodeGenerator CodeGenerator(Type enumType, GeneratorOptions options)
 {
     return(_options.AdditionPriority == AdditionPriority.Members
         ? (CodeGenerator) new MemberCSharpCodeGenerator(enumType, options)
         : new PropertyCSharpCodeGenerator(enumType, options));
 }
コード例 #53
0
 public LandingPageWriter(GeneratorOptions options)
     : base(options)
 {
 }