コード例 #1
0
        public IEnumerator IncludesScriptsInPlugins()
        {
            CreateFolder($"{Application.dataPath}/Test");
            CreateFolder($"{Application.dataPath}/Test/Hello");
            CopyScriptToAssetsFolder($"{Application.dataPath}/Test", "Test.asmdef", @"{ ""name"" : ""Test"" }");
            CopyScriptToAssetsFolder($"{Application.dataPath}/Test", "Script.cs", " ");
            CopyScriptToAssetsFolder($"{Application.dataPath}/Test", "Doc.txt", " ");
            CopyScriptToAssetsFolder($"{Application.dataPath}/Test/Hello", "Hello.txt", " ");
            var dir = Directory.GetParent(Application.dataPath).FullName;

            m_CsProjPath = Path.Combine(dir, "Test.csproj");

            yield return(new RecompileScripts(true));

            m_ProjectGeneration.Sync();

            var sourceFiles = new[]
            {
                "Test/Script.cs"
            };

            var textFiles = new[]
            {
                "Test/Test.asmdef",
                "Test/Doc.txt",
                "Test/Hello/Hello.txt"
            };

            var projectXml = XMLUtilities.FromFile(m_CsProjPath);

            XMLUtilities.AssertCompileItemsMatchExactly(projectXml, sourceFiles);
            XMLUtilities.AssertNonCompileItemsMatchExactly(projectXml, textFiles);
        }
コード例 #2
0
            public void UnsupportedExtension_IsOverWrittenBy_UserSupportedExtensions()
            {
                var unsupported  = new[] { "file.unsupported" };
                var synchronizer = m_Builder
                                   .WithAssetFiles(unsupported)
                                   .AssignFilesToAssembly(unsupported, m_Builder.Assembly)
                                   .WithUserSupportedExtensions(new[] { "unsupported" })
                                   .Build();

                synchronizer.Sync();
                var xmlDocument = XMLUtilities.FromText(m_Builder.ReadProjectFile(m_Builder.Assembly));

                XMLUtilities.AssertNonCompileItemsMatchExactly(xmlDocument, unsupported);
            }
コード例 #3
0
            public void InInternalizedPackage_WithoutGenerateAll_WillNotBeAddedToNonInclude()
            {
                var nonCompileItem  = "packageAsset.shader";
                var nonCompileItems = new[] { nonCompileItem };
                var synchronizer    = m_Builder
                                      .WithAssetFiles(nonCompileItems)
                                      .AssignFilesToAssembly(nonCompileItems, m_Builder.Assembly)
                                      .WithPackageAsset(nonCompileItem, true)
                                      .Build();

                synchronizer.Sync();
                var xmlDocument = XMLUtilities.FromText(m_Builder.ReadProjectFile(m_Builder.Assembly));

                XMLUtilities.AssertNonCompileItemsMatchExactly(xmlDocument, new string[0]);
            }
コード例 #4
0
            public void DllInSourceFiles_WillBeAddedAsReference()
            {
                var referenceDll = "reference.dll";
                var synchronizer = m_Builder
                                   .WithAssemblyData(files: new[] { "file.cs", referenceDll })
                                   .Build();

                synchronizer.Sync();

                var         csprojFileContents = m_Builder.ReadProjectFile(m_Builder.Assembly);
                XmlDocument scriptProject      = XMLUtilities.FromText(csprojFileContents);

                XMLUtilities.AssertCompileItemsMatchExactly(scriptProject, new[] { "file.cs" });
                XMLUtilities.AssertNonCompileItemsMatchExactly(scriptProject, new string[0]);
                Assert.That(csprojFileContents, Does.Match($"<Reference Include=\"reference\">\\W*<HintPath>{Regex.Escape(Path.Combine(SynchronizerBuilder.projectDirectory,referenceDll))}\\W*</HintPath>\\W*</Reference>"));
            }
コード例 #5
0
            public void BuiltinSupportedExtensions_InsideAssetFolder_WillBeAddedToNonCompileItems(string fileExtension)
            {
                var nonCompileItem = new[] { $"anotherFile.{fileExtension}" };
                var synchronizer   = m_Builder
                                     .WithAssetFiles(files: nonCompileItem)
                                     .AssignFilesToAssembly(nonCompileItem, m_Builder.Assembly)
                                     .Build();

                synchronizer.Sync();

                var         csprojContent = m_Builder.ReadProjectFile(m_Builder.Assembly);
                XmlDocument scriptProject = XMLUtilities.FromText(csprojContent);

                XMLUtilities.AssertCompileItemsMatchExactly(scriptProject, m_Builder.Assembly.sourceFiles);
                XMLUtilities.AssertNonCompileItemsMatchExactly(scriptProject, nonCompileItem);
            }
コード例 #6
0
            public void UnsupportedExtensions_WillNotBeAdded()
            {
                var unsupported  = new[] { "file.unsupported" };
                var synchronizer = m_Builder
                                   .WithAssetFiles(unsupported)
                                   .AssignFilesToAssembly(unsupported, m_Builder.Assembly)
                                   .Build();

                synchronizer.Sync();

                var csprojectContent = m_Builder.ReadProjectFile(m_Builder.Assembly);
                var xmlDocument      = XMLUtilities.FromText(csprojectContent);

                XMLUtilities.AssertCompileItemsMatchExactly(xmlDocument, m_Builder.Assembly.sourceFiles);
                XMLUtilities.AssertNonCompileItemsMatchExactly(xmlDocument, new string[0]);
            }
コード例 #7
0
        public IEnumerator DoesNotIncludeNonCSharpFiles()
        {
            CopyScriptToAssetsFolder(Application.dataPath, "SimpleCSharpScript.cs", k_EmptyCSharpScript);
            CopyScriptToAssetsFolder(Application.dataPath, "ClassDiagram1.cd", " ");
            CopyScriptToAssetsFolder(Application.dataPath, "text.txt", " ");
            CopyScriptToAssetsFolder(Application.dataPath, "Test.shader", " ");
            var dir = Directory.GetParent(Application.dataPath).FullName;

            m_CsProjPath = Path.Combine(dir, "Assembly-CSharp.csproj");

            yield return(new RecompileScripts(true));

            m_ProjectGeneration.Sync();

            var csProj = XMLUtilities.FromFile(m_CsProjPath);

            XMLUtilities.AssertCompileItemsMatchExactly(csProj, new [] { "SimpleCSharpScript.cs" });
            XMLUtilities.AssertNonCompileItemsMatchExactly(csProj, new [] { "text.txt", "ClassDiagram1.cd", "Test.shader" });
        }
コード例 #8
0
            public void NonCSharpFiles_AddedToNonCompileItems()
            {
                var nonCompileItems = new[]
                {
                    "UnityShader.uss",
                    "ComputerGraphic.cginc",
                    "Test.shader",
                };
                var synchronizer = m_Builder
                                   .WithAssetFiles(nonCompileItems)
                                   .AssignFilesToAssembly(nonCompileItems, m_Builder.Assembly)
                                   .Build();

                synchronizer.Sync();

                var csprojectContent = m_Builder.ReadProjectFile(m_Builder.Assembly);
                var xmlDocument      = XMLUtilities.FromText(csprojectContent);

                XMLUtilities.AssertCompileItemsMatchExactly(xmlDocument, m_Builder.Assembly.sourceFiles);
                XMLUtilities.AssertNonCompileItemsMatchExactly(xmlDocument, nonCompileItems);
            }