示例#1
0
        public string GererateString()
        {
            var output = new StringBuilder();

            foreach (var line in _originalData.ToString().Split('\n'))
            {
                output.AppendLine("//" + line);
            }
            output.AppendLine();

            var sourceParser = new CompileSourcesParser();

            sourceParser.Parse(_originalData.Element("sources"), null);

            output.AppendLine(sourceParser.GererateString());

            output.Append("FluentBuild.Core.Build.UsingCsc.Target.");
            output.AppendLine(FormatTarget());
            output.AppendLine("\t.AddSources(sourceFiles)");
            output.Append("\t.AddRefences(");

            foreach (var reference in References)
            {
                output.Append(reference + ", ");
            }
            output.Remove(output.Length - 2, 2); //remove the trailing comma + space
            output.AppendLine(")");
            output.AppendFormat("\t.OutputFileTo({0}){1}", Output, Environment.NewLine);
            output.AppendLine("\t.Execute();");
            return(output.ToString());
        }
示例#2
0
        public string GererateString()
        {
            var output = new StringBuilder();
            foreach (var line in _originalData.ToString().Split('\n'))
            {
                output.AppendLine("//" + line);
            }
            output.AppendLine();

            var sourceParser = new CompileSourcesParser();
            sourceParser.Parse(_originalData.Element("sources"), null);

            output.AppendLine(sourceParser.GererateString());

            output.Append("FluentBuild.Core.Build.UsingCsc.Target.");
            output.AppendLine(FormatTarget());
            output.AppendLine("\t.AddSources(sourceFiles)");
            output.Append("\t.AddRefences(");

            foreach (var reference in References)
            {
                output.Append(reference + ", ");
            }
            output.Remove(output.Length - 2, 2); //remove the trailing comma + space
            output.AppendLine(")");
            output.AppendFormat("\t.OutputFileTo({0}){1}", Output, Environment.NewLine);
            output.AppendLine("\t.Execute();");
            return output.ToString();
        }
 public void ShouldParseOneLine()
 {
     var data = new FileSetStatement();
     data.Type = "include";
     data.Name = "${dir.commons}/**/*.cs";
     var subject = new CompileSourcesParser();
     Assert.That(subject.ParseStatement(data), Is.EqualTo(".Include(${dir.commons}).RecurseAllSubDirectories.Filter(\"*.cs\")"));
     //var x =new FileSet().Include("").RecurseAllSubDirectories.Exclude()
 }
        public void ShouldParseOneLine()
        {
            var data = new FileSetStatement();

            data.Type = "include";
            data.Name = "${dir.commons}/**/*.cs";
            var subject = new CompileSourcesParser();

            Assert.That(subject.ParseStatement(data), Is.EqualTo(".Include(${dir.commons}).RecurseAllSubDirectories.Filter(\"*.cs\")"));
            //var x =new FileSet().Include("").RecurseAllSubDirectories.Exclude()
        }
        public void ShouldParse()
        {
            var _input = new StringBuilder();
            _input.AppendLine("  <sources>");
            _input.AppendLine("      <include name=\"${dir.commons}/**/*.cs\"/>");
            _input.AppendLine("      <exclude name=\"${dir.commons}/**/AssemblyInfo.cs\"/>");
            _input.AppendLine("      <include name=\"${dir.compile}/CommonAssemblyInfo.cs\"/>");
            _input.AppendLine("  </sources>");

            var subject = new CompileSourcesParser();
            subject.Parse(XElement.Parse(_input.ToString()), null);
            Assert.That(subject.Statements[0].Type, Is.EqualTo("include"));
            Assert.That(subject.Statements[0].Name, Is.EqualTo("${dir.commons}/**/*.cs"));

            Assert.That(subject.Statements[1].Type, Is.EqualTo("exclude"));
            Assert.That(subject.Statements[1].Name, Is.EqualTo("${dir.commons}/**/AssemblyInfo.cs"));

            Assert.That(subject.Statements[2].Type, Is.EqualTo("include"));
            Assert.That(subject.Statements[2].Name, Is.EqualTo("${dir.compile}/CommonAssemblyInfo.cs"));
        }
        public void ShouldParse()
        {
            var _input = new StringBuilder();

            _input.AppendLine("  <sources>");
            _input.AppendLine("      <include name=\"${dir.commons}/**/*.cs\"/>");
            _input.AppendLine("      <exclude name=\"${dir.commons}/**/AssemblyInfo.cs\"/>");
            _input.AppendLine("      <include name=\"${dir.compile}/CommonAssemblyInfo.cs\"/>");
            _input.AppendLine("  </sources>");

            var subject = new CompileSourcesParser();

            subject.Parse(XElement.Parse(_input.ToString()), null);
            Assert.That(subject.Statements[0].Type, Is.EqualTo("include"));
            Assert.That(subject.Statements[0].Name, Is.EqualTo("${dir.commons}/**/*.cs"));

            Assert.That(subject.Statements[1].Type, Is.EqualTo("exclude"));
            Assert.That(subject.Statements[1].Name, Is.EqualTo("${dir.commons}/**/AssemblyInfo.cs"));

            Assert.That(subject.Statements[2].Type, Is.EqualTo("include"));
            Assert.That(subject.Statements[2].Name, Is.EqualTo("${dir.compile}/CommonAssemblyInfo.cs"));
        }