Пример #1
0
        protected override IEnumerable <CodeFragment> GetCodeFragments()
        {
            var classNamespace = StringUtility.IsNullOrEmpty(Namespace) ? null : Namespace;
            var className      = StringUtility.IsNullOrEmpty(ClassName) ? "ThisAssembly" : ClassName;
            var constants      = (Constants ?? Enumerable.Empty <ITaskItem>()).Select(ExtractConstantDefinitionFromItem);
            var fragment       = new ThisAssemblyClass(classNamespace, className, constants);

            yield return(fragment);
        }
Пример #2
0
        public void GenerateCode_ReturnsNonEmptyString(string languageStr)
        {
            var assemblyAttribute = new AssemblyAttribute(
                "System.Runtime.InteropServices.ComVisible",
                new[] { new OrderedParameter(false) });

            var thisAssemblyClass = new ThisAssemblyClass(
                null,
                "ThisAssembly",
                new[] { new Constant("Answer", 42) });

            _ = CodeGeneratorConfigurationUtility.TryParseLanguage(languageStr, out var language);
            var configuration = new GeneratedCode(
                language,
                new CodeFragment[] { assemblyAttribute, thisAssemblyClass });

            var code = CodeGenerator.GenerateCode(configuration);

            Assert.IsNotNull(code);
            Assert.IsNotEmpty(code);
        }
Пример #3
0
 protected abstract TSyntaxNode GenerateThisAssemblyClass(ThisAssemblyClass thisAssemblyClass);