Exemplo n.º 1
0
            public void RoslynAnalyzerRulesetFiles_WillBeIncluded()
            {
                var roslynAnalyzerRuleSetPath = "Assets/RoslynRuleSet.ruleset";

                m_Builder.WithAssemblyData(files: new[] { "file.cs" }, roslynAnalyzerRulesetPath: roslynAnalyzerRuleSetPath).Build().Sync();
                var         csProjectFileContents = m_Builder.ReadProjectFile(m_Builder.Assembly);
                XmlDocument csProjectXmlFile      = XMLUtilities.FromText(csProjectFileContents);

                XMLUtilities.AssertAnalyzerRuleSetsMatchExactly(csProjectXmlFile, roslynAnalyzerRuleSetPath);
            }
Exemplo n.º 2
0
            public void RoslynAnalyzerDlls_WillBeIncluded()
            {
                var roslynAnalyzerDllPath = "Assets\\RoslynAnalyzer.dll";
                var synchronizer          = m_Builder.WithRoslynAnalyzers(new[] { roslynAnalyzerDllPath }).Build();

                synchronizer.Sync();

                string      projectFile    = m_Builder.ReadProjectFile(m_Builder.Assembly);
                XmlDocument projectFileXml = XMLUtilities.FromText(projectFile);

                XMLUtilities.AssertAnalyzerItemsMatchExactly(projectFileXml, new[] { MakeAbsolutePath(roslynAnalyzerDllPath).NormalizePath() });
            }
Exemplo n.º 3
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" });
            }
Exemplo n.º 4
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);
            }
Exemplo n.º 5
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);
            }
Exemplo n.º 6
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 });
            }
Exemplo n.º 7
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 });
            }
Exemplo n.º 8
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);
            }
            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]);
            }
Exemplo n.º 10
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>"));
            }
Exemplo n.º 11
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);
            }
Exemplo n.º 12
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]);
            }
Exemplo n.º 13
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);
            }
Exemplo n.º 14
0
            public void ProjectReference_MatchAssemblyGUID()
            {
                string[] files        = { "test.cs" };
                var      assemblyB    = new Assembly("Test", "Temp/Test.dll", files, new string[0], new Assembly[0], new string[0], AssemblyFlags.None);
                var      assemblyA    = new Assembly("Test2", "some/path/file.dll", files, new string[0], new[] { assemblyB }, new[] { "Library.ScriptAssemblies.Test.dll" }, AssemblyFlags.None);
                var      synchronizer = m_Builder.WithAssemblies(new[] { assemblyA, assemblyB }).Build();

                synchronizer.Sync();

                var assemblyACSproject = MakeAbsolutePath($"{assemblyA.name}.csproj");
                var assemblyBCSproject = MakeAbsolutePath($"{assemblyB.name}.csproj");

                Assert.True(m_Builder.FileExists(assemblyACSproject));
                Assert.True(m_Builder.FileExists(assemblyBCSproject));

                XmlDocument scriptProject       = XMLUtilities.FromText(m_Builder.ReadFile(assemblyACSproject));
                XmlDocument scriptPluginProject = XMLUtilities.FromText(m_Builder.ReadFile(assemblyBCSproject));

                var a = XMLUtilities.GetInnerText(scriptPluginProject, "/msb:Project/msb:PropertyGroup/msb:ProjectGuid");
                var b = XMLUtilities.GetInnerText(scriptProject, "/msb:Project/msb:ItemGroup/msb:ProjectReference/msb:Project");

                Assert.AreEqual(a, b);
            }