public void GetPathForGeneratedScript()
        {
            string path0 = CodeGenerateEditorUtility.GetPathForGeneratedScript("Assets/Code/Script.cs");
            string path1 = CodeGenerateEditorUtility.GetPathForGeneratedScript("Assets/Code/Script.cs", "Label");

            Assert.AreEqual("Assets/Code/Script.Generated.cs", path0);
            Assert.AreEqual("Assets/Code/Script.Label.Generated.cs", path1);
        }
        public void CheckAttributeFromScript()
        {
            INamedTypeSymbol typeSymbol = m_compilation.GetTypeByMetadataName(typeof(TestAttribute).FullName);

            bool result = CodeGenerateEditorUtility.CheckAttributeFromScript(m_compilation, m_targetWithAttribute, typeSymbol);

            Assert.True(result);
        }
        public void AddGeneratedCodeLeadingTrivia()
        {
            string sourceWith    = File.ReadAllText(m_targetWithGeneratedCodeLeadingTrivia);
            string sourceWithout = File.ReadAllText(m_targetWithoutGeneratedCodeLeadingTrivia);

            SyntaxNode node = SyntaxFactory.ParseSyntaxTree(sourceWithout).GetRoot();

            node = CodeGenerateEditorUtility.AddGeneratedCodeLeadingTrivia(node);

            string result = node.ToFullString();

            Assert.AreEqual(sourceWith, result);
        }
Esempio n. 4
0
        public static string GenerateResolver(IReadOnlyList <string> sourcePaths, string resolverName, string namespaceRoot, Utf8JsonGenerateArguments generateArguments)
        {
            if (sourcePaths == null)
            {
                throw new ArgumentNullException(nameof(sourcePaths));
            }
            if (string.IsNullOrEmpty(resolverName))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(resolverName));
            }
            if (string.IsNullOrEmpty(namespaceRoot))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(namespaceRoot));
            }

            string resolver            = Utf8JsonUniversalCodeGeneratorUtility.Generate(sourcePaths, resolverName, namespaceRoot, generateArguments);
            CompilationUnitSyntax unit = SyntaxFactory.ParseCompilationUnit(resolver);

            unit = CodeGenerateEditorUtility.AddGeneratedCodeLeadingTrivia(unit);

            return(unit.ToFullString());
        }
        public void CheckAttributeFromScriptFromType()
        {
            bool result = CodeGenerateEditorUtility.CheckAttributeFromScript(m_compilation, m_targetWithAttribute, typeof(TestAttribute));

            Assert.True(result);
        }