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);
        }
Esempio n. 2
0
            public void AbsoluteSourceFilePaths_WillBeMadeRelativeToProjectDirectory()
            {
                var absoluteFilePath = MakeAbsolutePath("dimmer.cs");
                var synchronizer     = m_Builder.WithAssemblyData(files: new[] { absoluteFilePath }).Build();

                synchronizer.Sync();

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

                XMLUtilities.AssertCompileItemsMatchExactly(scriptProject, new[] { "dimmer.cs" });
            }
Esempio n. 3
0
            public void BuiltinSupportedExtensions_InsideAssemblySourceFiles_WillBeAddedToCompileItems(string fileExtension)
            {
                var compileItem  = new[] { "file.cs", $"anotherFile.{fileExtension}" };
                var synchronizer = m_Builder.WithAssemblyData(files: compileItem).Build();

                synchronizer.Sync();

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

                XMLUtilities.AssertCompileItemsMatchExactly(scriptProject, compileItem);
            }
Esempio n. 4
0
            public void NoExtension_IsNotValid()
            {
                var validFile    = "dimmer.cs";
                var invalidFile  = "foo";
                var file         = new[] { validFile, invalidFile };
                var synchronizer = m_Builder.WithAssemblyData(files: file).Build();

                synchronizer.Sync();

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

                XMLUtilities.AssertCompileItemsMatchExactly(scriptProject, new[] { validFile });
            }
Esempio n. 5
0
            public void FullPathAsset_WillBeConvertedToRelativeFromProjectDirectory()
            {
                var assetPath    = "Assets/Asset.cs";
                var synchronizer = m_Builder
                                   .WithAssemblyData(files: new[] { MakeAbsolutePath(assetPath) })
                                   .Build();

                synchronizer.Sync();

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

                XMLUtilities.AssertCompileItemsMatchExactly(xmlDocument, new[] { assetPath });
            }
Esempio n. 6
0
            public void MultipleSourceFiles_WillAllBeAdded()
            {
                var files        = new[] { "fileA.cs", "fileB.cs", "fileC.cs" };
                var synchronizer = m_Builder
                                   .WithAssemblyData(files: files)
                                   .Build();

                synchronizer.Sync();

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

                XMLUtilities.AssertCompileItemsMatchExactly(xmlDocument, files);
            }
Esempio n. 7
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>"));
            }
Esempio n. 8
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);
            }
Esempio n. 9
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]);
            }
        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" });
        }
Esempio n. 11
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);
            }