Beispiel #1
0
        /// <summary>
        ///     Deletes the comment.
        /// </summary>
        /// <param name="project_id">The project_id is the identifier of the project.</param>
        /// <param name="comment_id">The comment_id is the identifier of the comment for the specified project.</param>
        /// <returns>System.String.<br></br>The success message is "The comment has been deleted."</returns>
        public string DeleteComment(string project_id, string comment_id)
        {
            var url      = baseAddress + "/" + project_id + "/comments/" + comment_id;
            var responce = ZohoHttpClient.delete(url, getQueryParameters());

            return(ProjectParser.getMessage(responce));
        }
Beispiel #2
0
        /// <summary>
        ///     List all projects with pagination.
        /// </summary>
        /// <param name="parameters">
        ///     The parameters is the Dictionary object which contains the filters in the form of key, value pair to refine the
        ///     list.<br></br>The possible filters are listed below<br></br>
        ///     <table>
        ///         <tr>
        ///             <td>filter_by</td>
        ///             <td>
        ///                 Filter projects by any status<br></br>Allowed Values: <i>Status.All, Status.Active</i> and
        ///                 <i>Status.Inactive</i>
        ///             </td>
        ///         </tr>
        ///         <tr>
        ///             <td>customer_id</td><td>Search projects by customer id.</td>
        ///         </tr>
        ///         <tr>
        ///             <td>sort_column</td>
        ///             <td>
        ///                 Sort projects<br></br>Allowed Values: <i>project_name, customer_name, rate</i> and <i>created_time</i>
        ///             </td>
        ///         </tr>
        ///     </table>
        /// </param>
        /// <returns>ProjectsList object.</returns>
        public ProjectsList GetProjects(Dictionary <object, object> parameters)
        {
            var url      = baseAddress;
            var responce = ZohoHttpClient.get(url, getQueryParameters(parameters));

            return(ProjectParser.getProjectsList(responce));
        }
Beispiel #3
0
        /// <summary>
        ///     Start tracking time spent.
        /// </summary>
        /// <param name="time_entry_id">The time_entry_id is the identifier of the time entry.</param>
        /// <returns>TimeEntry object.</returns>
        public TimeEntry StartTimer(string time_entry_id)
        {
            var url      = baseAddress + "/timeentries/" + time_entry_id + "/timer/start";
            var responce = ZohoHttpClient.post(url, getQueryParameters());

            return(ProjectParser.getTimeEntry(responce));
        }
Beispiel #4
0
        /// <summary>
        ///     Stop tracking time, say taking a break or leaving.
        /// </summary>
        /// <returns>TimeEntry object.</returns>
        public TimeEntry StopTimer()
        {
            var url      = baseAddress + "/timeentries/timer/stop";
            var responce = ZohoHttpClient.post(url, getQueryParameters());

            return(ProjectParser.getTimeEntry(responce));
        }
Beispiel #5
0
        /// <summary>
        ///     Deletes the logged time entries.
        /// </summary>
        /// <param name="parameters">
        ///     The parameters is the dictionary object which contains the following mandatory parameter in the key,value pair
        ///     format.<br></br>
        ///     <table>
        ///         <tr>
        ///             <td>time_entry_ids*</td><td>IDs of the time entries to be deleted.</td>
        ///         </tr>
        ///     </table>
        /// </param>
        /// <returns>System.String.<br></br>The success message is "The selected timesheet entries have been deleted"</returns>
        public string DeleteTimeEntries(Dictionary <object, object> parameters)
        {
            var url      = baseAddress + "/timeentries";
            var responce = ZohoHttpClient.delete(url, getQueryParameters(parameters));

            return(ProjectParser.getMessage(responce));
        }
Beispiel #6
0
        /// <summary>
        ///     Get current running timer.
        /// </summary>
        /// <returns>TimeEntry object.</returns>
        public TimeEntry GetTimer()
        {
            var url      = baseAddress + "/timeentries/runningtimer/me";
            var responce = ZohoHttpClient.get(url, getQueryParameters());

            return(ProjectParser.getTimeEntry(responce));
        }
Beispiel #7
0
//------------------------------------------------------------------------------------------------------
        /// <summary>
        ///     List all time entries with pagination.
        /// </summary>
        /// <param name="parameters">
        ///     The parameters is the Dictionary object which contains the filters in the form of key,value pair to refine the
        ///     list.<br></br>The possible filters are listed below<br></br>
        ///     <table>
        ///         <tr>
        ///             <td>from_date</td><td>Date from which the time entries logged to be fetched</td>
        ///         </tr>
        ///         <tr>
        ///             <td>to_date</td><td>Date up to which the time entries logged to be fetched</td>
        ///         </tr>
        ///         <tr>
        ///             <td>filter_by</td>
        ///             <td>
        ///                 Filter time entries by date and status.<br></br>Allowed Values:
        ///                 <i>
        ///                     Date.All, Date.Today, Date.ThisWeek, Date.ThisMonth, Date.ThisQuarter, Date.ThisYear,
        ///                     Date.PreviousDay, Date.PreviousWeek, Date.PreviousMonth, Date.PreviousQuarter, Date.PreviousYear,
        ///                     Date.CustomDate, Status.Unbilled
        ///                 </i>
        ///                 and <i>Status.Invoiced</i>
        ///             </td>
        ///         </tr>
        ///         <tr>
        ///             <td>project_id</td><td>Search time entries by project_id.</td>
        ///         </tr>
        ///         <tr>
        ///             <td>user_id</td><td>Search time entries by user_id.</td>
        ///         </tr>
        ///         <tr>
        ///             <td>sort_column</td>
        ///             <td>
        ///                 Sort time entries.<br></br>Allowed Values:
        ///                 <i>project_name, task_name, user_name, log_date, timer_started_at</i> and <i>customer_name</i>
        ///             </td>
        ///         </tr>
        ///     </table>
        /// </param>
        /// <returns>TimeEntrisList object.</returns>
        public TimeEntryList GetTimeEnries(Dictionary <object, object> parameters)
        {
            var url      = baseAddress + "/timeentries";
            var responce = ZohoHttpClient.get(url, getQueryParameters(parameters));

            return(ProjectParser.getTimeEntrieslist(responce));
        }
Beispiel #8
0
        /// <summary>
        ///     Deletes the logged time entry.
        /// </summary>
        /// <param name="time_entry_id">The time_entry_id is the identifier of the time entry.</param>
        /// <returns>System.String.<br></br>The success message is "The time entry has been deleted" </returns>
        public string DeleteTimeEntry(string time_entry_id)
        {
            var url      = baseAddress + "/timeentries/" + time_entry_id;
            var responce = ZohoHttpClient.delete(url, getQueryParameters());

            return(ProjectParser.getMessage(responce));
        }
Beispiel #9
0
        /// <summary>
        ///     Get details of a user in a project.
        /// </summary>
        /// <param name="project_id">The project_id is the identifier of the project.</param>
        /// <param name="user_id">The user_id is the identifier of the user who is associated with the specified project.</param>
        /// <returns>User object.</returns>
        public User GetAUser(string project_id, string user_id)
        {
            var url      = baseAddress + "/" + project_id + "/users/" + user_id;
            var responce = ZohoHttpClient.get(url, getQueryParameters());

            return(ProjectParser.getUser(responce));
        }
Beispiel #10
0
        /// <summary>
        ///     Gets the details of a task.
        /// </summary>
        /// <param name="project_id">The project_id is the identifier of the project.</param>
        /// <param name="task_id">The task_id is the identifier of the task of specified project.</param>
        /// <returns>ProjectTask object.</returns>
        public ProjectTask GetATask(string project_id, string task_id)
        {
            var url      = baseAddress + "/" + project_id + "/tasks/" + task_id;
            var responce = ZohoHttpClient.get(url, getQueryParameters());

            return(ProjectParser.gettask(responce));
        }
Beispiel #11
0
//--------------------------------------------------------------------------------------

        /// <summary>
        ///     Get list of tasks added to a project.
        /// </summary>
        /// <param name="project_id">The project_id is the identifier of the project.</param>
        /// <param name="parameters">
        ///     The parameters is the Dictionary object which contains the filters in the form of key,value pair to refine the
        ///     list.<br></br>The possible filters are listed below<br></br>
        ///     <table>
        ///         <tr>
        ///             <td>sort_column</td>
        ///             <td>
        ///                 Sort tasks<br></br>Allowed Values: <i>task_name, billed_hours, log_time</i> and <i>un_billed_hours</i>
        ///             </td>
        ///         </tr>
        ///     </table>
        /// </param>
        /// <returns>TasksList object.</returns>
        public TaskList GetTasks(string project_id, Dictionary <object, object> parameters)
        {
            var url      = baseAddress + "/" + project_id + "/tasks";
            var responce = ZohoHttpClient.get(url, getQueryParameters(parameters));

            return(ProjectParser.gatTaskList(responce));
        }
Beispiel #12
0
        /// <summary>
        ///     Get the details of a project.
        /// </summary>
        /// <param name="project_id">The project_id is the identifier of the project.</param>
        /// <returns>Project object.</returns>
        public Project Get(string project_id)
        {
            var url      = baseAddress + "/" + project_id;
            var responce = ZohoHttpClient.get(url, getQueryParameters());

            return(ProjectParser.getProject(responce));
        }
Beispiel #13
0
        internal void CompareTrees(IEnumerable <string> sources, IEnumerable <string> fileNames, IEnumerable <ErrorCode> errors, [CallerMemberName] string testName = "")
        {
            Errors.Clear();

            var    file         = path + testName;
            var    compilerArgs = CompilerArguments.Parse(fileNames.Select(n => Path.Combine("$" + testName, n)).Union(new[] { string.Format("/out:{0}.exe", testName) }).ToArray());
            var    parser       = ProjectParser.ParseAll(assembly, compilerArgs, sources.ToArray(), false);
            string result       = parser.ToString();

            string expected = "";

#if REWRITE
            System.IO.File.WriteAllText(file, result);
            expected = result;
#else
            try
            {
                expected = System.IO.File.ReadAllText(file);
            }
            catch { }
#endif
            var foundErrors    = Errors.Reported.Select(e => e.ErrorCode).ToHashSet();
            var expectedErrors = errors.ToHashSet();


            Assert.IsTrue(foundErrors.SetEquals(expectedErrors), "Errors: \r\n" + String.Join("\r\n", Errors.Reported));
            Assert.AreEqual(expected, result);
        }
Beispiel #14
0
        public TargetProject LoadFromProjectFile(string targetProjectPath)
        {
            ProjectParser parser    = new ProjectParser();
            var           csProject = parser.ParseFile(targetProjectPath);

            return(LoadFromProjectFile(csProject, targetProjectPath));
        }
Beispiel #15
0
        public Processor(
            CommandLineService commandLineService,
            ProjectParser projectParser,
            ProcessRunner processRunner,
            ILogger <Processor> logger)
        {
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
                                                          logger.LogCritical("发生了灾难性故障。请联系开发者反馈错误。\n" +
                                                                             ((e.ExceptionObject as Exception)?.Message ?? string.Empty));

            try
            {
                switch (commandLineService.Options)
                {
                case ProcessOptions:
                    processRunner.Run(projectParser.Parse());
                    break;

                default:
                    throw new IndexOutOfRangeException("不支持的命令类型。");
                }
            }
            catch (Exception e)
            {
                logger.LogCritical(e, "处理命令时出现错误。");
                Environment.Exit(1);
            }

            logger.LogInformation("完成了所有的操作。");
        }
Beispiel #16
0
        public ProjectParser GetXmlParser(Options options)
        {
            var serviceBuilder = new ServiceBuilder();

            serviceBuilder.Setup(options);
            serviceBuilder.Build();

            var rootPath         = GetRootPath(options);
            var parentFolder     = GetParentFolder(options);
            var namingConvention = GetNamingConvention(options);


            var parser = new ProjectParser()
            {
                ParentFolder     = parentFolder,
                RootPath         = rootPath,
                NamingConvention = namingConvention
            };

            var policyParser     = new PolicyParser(serviceBuilder.GetPolicyService());
            var dataSourceParser = new DataSourceParser(serviceBuilder.GetDataSourceService());
            var reportParser     = new ReportParser(serviceBuilder.GetReportService(), new[] { policyParser });
            var folderParser     = new FolderParser(serviceBuilder.GetFolderService(), new IParser[] { policyParser, dataSourceParser, reportParser });

            parser.ChildParsers.Add(dataSourceParser);
            parser.ChildParsers.Add(reportParser);
            parser.ChildParsers.Add(folderParser);

            return(parser);
        }
Beispiel #17
0
 public SolutionParser(TokenWalker tokenWalker, HeaderParser headerParser, ProjectParser projectParser, GlobalSectionParser globalSectionParser)
 {
     _tokenWalker         = tokenWalker;
     _headerParser        = headerParser;
     _projectParser       = projectParser;
     _globalSectionParser = globalSectionParser;
 }
        /// <summary>
        /// Gets the details of the current user.
        /// </summary>
        /// <returns>User object.</returns>
        public User GetCurrentUser()
        {
            string url      = baseAddress + "/me";
            var    response = ZohoHttpClient.get(url, getQueryParameters());

            return(ProjectParser.getUser(response));
        }
Beispiel #19
0
            public void TestEnsureFileIncludeExistingDependentNode()
            {
                string data =
                    @"<?xml version=""1.0"" encoding=""utf-8""?>
					<Project DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
						<ItemGroup>
							<Compile Include=""TestDirectory\TestClass1.aspx.cs"">
							  <DependentUpon>SomethingElse.aspx</DependentUpon>
							</Compile>
						</ItemGroup>
					</Project>
				"                ;
                ProjectParser parser = new ProjectParser();
                bool          anyChange;
                string        actualResult = parser.EnsureFileInclude(data, "C:\\Test\\TestProject.csproj", "C:\\Test\\TestDirectory\\TestClass1.aspx.cs", "C:\\Test\\TestDirectory\\TestClass1.aspx", out anyChange);

                Assert.IsTrue(anyChange);
                string expectedResult =
                    @"<?xml version=""1.0"" encoding=""utf-8""?>
					<Project DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
						<ItemGroup>
							<Compile Include=""TestDirectory\TestClass1.aspx.cs"">
							  <DependentUpon>TestClass1.aspx</DependentUpon>
							</Compile>
						</ItemGroup>
					</Project>
				"                ;

                this.CompareXml(expectedResult, actualResult);
            }
Beispiel #20
0
			public void TestBasicProject()
			{
				string data =
				@"<?xml version=""1.0"" encoding=""utf-8""?>
					<Project DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
						<PropertyGroup>
						<Configuration Condition="" '$(Configuration)' == '' "">Debug</Configuration>
							<OutputType>Library</OutputType>
							<AppDesignerFolder>Properties</AppDesignerFolder>
							<RootNamespace>TestRootNamespace</RootNamespace>
							<RestorePackages>true</RestorePackages>
						</PropertyGroup>
						<ItemGroup>
							<Compile Include=""TestClass1.cs"" />
						</ItemGroup>
					</Project>
				";
				Mock<ClassParser> classParser = new Mock<ClassParser>();
				List<CSClass> classList = new List<CSClass>();
				var testClass1 = new CSClass()
				{
					ClassName = "TestClass1",
					NamespaceName = "Test.Test1"
				};
				classList.Add(testClass1);
				classParser.Setup(i => i.ParseFile("C:\\Test\\TestClass1.cs", It.IsAny<string>(), It.IsAny<IEnumerable<CSClass>>())).Returns(classList);

				ProjectParser parser = new ProjectParser(classParser.Object);

				CSProjectFile project = parser.ParseString(data, "C:\\Test\\TestProject.csproj");
			
				Assert.AreEqual("TestRootNamespace", project.RootNamespace);
				Assert.AreEqual(1, project.ClassList.Count);
				Assert.AreEqual("Test.Test1.TestClass1", project.ClassList[0].ClassFullName);
			}
        public override bool Handle(ProjectParser project)
        {
            var changed = false;

            var root = project.RootElement;
            var propertyGroups = root.PropertyGroups;
            foreach (var propertyGroup in propertyGroups)
            {
                //System.Diagnostics.Debug.WriteLine("PropertyGroup(" + propertyGroup.Condition + ")");

                var sccProperties = propertyGroup.AllChildren.Where(x => x is ProjectPropertyElement);
                foreach (ProjectPropertyElement sccProperty in sccProperties)
                {
                    if (!sccProperty.Name.StartsWith("Scc")) continue;

                    //System.Diagnostics.Debug.WriteLine(sccProperty);
                    propertyGroup.RemoveChild(sccProperty);
                    changed = true;
                }
            }

            var directoryInfo = new DirectoryInfo(project.DirectoryPath);
            var sccFiles = directoryInfo.EnumerateFiles("*.vspscc").Concat(directoryInfo.EnumerateFiles("*.vssscc"));
            foreach (var sccFile in sccFiles)
            {
                sccFile.MoveTo(sccFile.FullName+".bak");
            }
            return changed;
        }
        private IParsedProject GetSelectedProject()
        {
            var selectedProjectDirectory = GetSelectedProjectDirectory();

            if (selectedProjectDirectory == null)
            {
                return(null);
            }

            // Fetch the project that lives in that directory and parse it.
            var projects = GetSolutionProjects();

            foreach (Project p in projects)
            {
                var projectDirectory = Path.GetDirectoryName(p.FullName);
                if (projectDirectory.Equals(selectedProjectDirectory, StringComparison.OrdinalIgnoreCase))
                {
                    return(ProjectParser.ParseProject(p));
                }
            }

            // Failed to determine the project.
            Debug.WriteLine($"Could not find a project in {selectedProjectDirectory}");
            return(null);
        }
Beispiel #23
0
        private static ParseResult ParseDirectoryFiles(Config configuration, Arguments arguments)
        {
            var         projectParser = new ProjectParser(arguments.Target, configuration.PHPSettings);
            ParseResult parseResult   = projectParser.ParseProjectFiles();

            return(parseResult);
        }
Beispiel #24
0
        /// <summary>
        ///     Marks a project as inactive.
        /// </summary>
        /// <param name="project_id">The project_id is the identifier of the project.</param>
        /// <returns>System.String.<br></br>The success message is "The selected projects have been marked as inactive."</returns>
        public string Inactivate(string project_id)
        {
            var url      = baseAddress + "/" + project_id + "/inactive";
            var responce = ZohoHttpClient.post(url, getQueryParameters());

            return(ProjectParser.getMessage(responce));
        }
        public void ShouldGetAllDependencies(string fileName, Dependency[] expected)
        {
            // All the test projects are named ".csproj1" because for some reason the compiler want to load them when they are called just ".csproj" and errors out
            var dependencies = ProjectParser.GetAllDependencies($"./sample-projects/{fileName}.csproj1");

            Assert.Equal(expected, dependencies.ToArray());
        }
        private void CollectWAVFilesUsage(ProjectParser parser, ProjectInfo project)
        {
            foreach (var chan in parser.project.Channels)
            {
                var chanData = chan.Data as Monad.FLParser.GeneratorData;

                if (chanData != null && !string.IsNullOrWhiteSpace(chanData.SampleFileName))
                {
                    var wavFilename = chanData.SampleFileName;

                    try
                    {
                        // try to fix file path, if hard drives were mysteriously changed
                        if (!File.Exists(wavFilename))
                        {
                            var wavLocation = Helpers.NormalizePath(Path.GetDirectoryName(chanData.SampleFileName));

                            if (string.Compare(wavLocation.Substring(1), project.ProjectPath.Substring(1), StringComparison.InvariantCultureIgnoreCase) == 0)
                            {
                                wavFilename = Path.Combine(project.ProjectPath, Path.GetFileName(wavFilename));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        project.FileError = true;
                    }

                    project.UsedWAVList.Add(wavFilename);
                }
            }
        }
Beispiel #27
0
        private Project LoadBuildScript()
        {
            var stream  = typeof(BuildEnvironment).Assembly.GetManifestResourceStream("Build.Microsoft.Common.props");
            var project = new ProjectParser(_fileSystem).Parse(stream, "Common.props");

            return(project);
        }
        private static int Compile(params string[] args)
        {
            Errors.Clear();

            var compilerArgs = CompilerArguments.Parse(args);

            if (compilerArgs.HasErrors)
            {
                return(FailCompilation());
            }

            AssemblyRegistry.Create(compilerArgs.References);
            var assembly = new AssemblyEmitter(compilerArgs);

            ProjectParser.ParseAll(assembly, compilerArgs, true);

            if (Errors.Reported.Count > 0)
            {
                return(FailCompilation());
            }

            if (!assembly.Save())
            {
                return(FailCompilation());
            }

            return(0);
        }
Beispiel #29
0
        public void ProjectParser_GetReferencedFilesForProject_ParsesAllFilesFromMultipleItemGroups()
        {
            string referencedFile1 = @"Controllers\Controller.cs";
            string referencedFile2 = @"Models\Model.cs";
            string referencedFile3 = @"Views\View.cshtml";
            string referencedFile4 = @"Web.config";

            string projectXml = String.Format(
                @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<ItemGroup>
						<Item Include=""{0}"" />
						<Item Include=""{1}"" />
					</ItemGroup>
					<ItemGroup>
						<Item Include=""{2}"" />
						<Item Include=""{3}"" />
					</ItemGroup>
				</Project>"                , referencedFile1, referencedFile2, referencedFile3, referencedFile4);

            XElement projectElement = XElement.Parse(projectXml);

            ProjectParser          projectParser          = new ProjectParser();
            ReferencedProjectFiles referencedProjectFiles = projectParser.GetReferencedFilesForProject(projectElement);

            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile1));
            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile2));
            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile3));
            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile4));
        }
Beispiel #30
0
    // test implementation for the pitch detection pipeline
    static void Main(string[] args)
    {
        // load an ultrastar project (notes & song)
        ProjectParser projectParser = new ProjectParser();

        projectParser.loadNoteFile("/path/to/notes.txt");
        IEnumerable <float[]> audioSegmentsIter = projectParser.readMonoWav16("/path/to/16khz/mono/song.wav");
        // init the audio preprocessor
        AudioPreprocessor audioPreprocessor = new AudioPreprocessor(
            Path.Join("Assets", "Binaries", "Pca", "pcaMeanFp32.npy"),
            Path.Join("Assets", "Binaries", "Pca", "pcaCompFp32.npy"));
        // init the pitch classifier
        PitchClassifier pitchClassifier = new PitchClassifier(
            Path.Join("Assets", "Binaries", "Model", "modelWeights1TransposedFp32.npy"),
            Path.Join("Assets", "Binaries", "Model", "modelWeights2TransposedFp32.npy"),
            Path.Join("Assets", "Binaries", "Model", "modelBias1Fp32.npy"),
            Path.Join("Assets", "Binaries", "Model", "modelBias2Fp32.npy"));

        // iterate over each audio segment
        foreach (float[] segment in audioSegmentsIter)
        {
            // transform segment to a list of features
            float[][] features = audioPreprocessor.transform(segment);
            // determine the most likely pitch for the segment
            int pitch = pitchClassifier.predictBatch(features);
        }
    }
Beispiel #31
0
        public void ProjectParser_GetReferencedFilesForProject_IgnoresReferencedAssemblies()
        {
            string nonReferencedFile1 = @"Microsoft.CSharp";
            string nonReferencedFile2 = @"System.Data";
            string referencedFile1    = @"Controllers\Controller.cs";
            string referencedFile2    = @"Web.config";

            string projectXml = String.Format(
                @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<ItemGroup>
						<Reference Include=""{0}"" />
						<Reference Include=""{1}"" />
					</ItemGroup>
					<ItemGroup>
						<Item Include=""{2}"" />
						<Item Include=""{3}"" />
					</ItemGroup>
				</Project>"                , nonReferencedFile1, nonReferencedFile2, referencedFile1, referencedFile2);

            XElement projectElement = XElement.Parse(projectXml);

            ProjectParser          projectParser          = new ProjectParser();
            ReferencedProjectFiles referencedProjectFiles = projectParser.GetReferencedFilesForProject(projectElement);

            Assert.False(referencedProjectFiles.IsFileReferenced(nonReferencedFile1));
            Assert.False(referencedProjectFiles.IsFileReferenced(nonReferencedFile2));

            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile1));
            Assert.True(referencedProjectFiles.IsFileReferenced(referencedFile2));
        }
Beispiel #32
0
        public void ProjectParser()
        {
            var           existingPath = @"Data\BSMLPractice.csproj";
            ProjectParser parser       = new ProjectParser(existingPath);

            if (parser.TryParseProjectFile(out var results))
            {
                Assert.IsFalse(string.IsNullOrEmpty(results.BeatSaberDir));
                Assert.IsFalse(string.IsNullOrEmpty(results.ManifestFilePath));
                Assert.IsFalse(string.IsNullOrEmpty(results.PostBuildEvent));
                Assert.IsNotNull(results.Document);
                Assert.IsNotNull(results.MainPropertyGroupElement);
                Assert.IsNotNull(results.PostBuildEventElement);
                Assert.IsTrue(results.Targets.Count > 0);
                Assert.IsTrue(results.BuildTasks.Count > 0);
                Assert.IsTrue(results.References.Count > 0);
                Assert.IsTrue(results.References.TrueForAll(r => r.ParentGroup != null));
                Assert.IsTrue(results.References.Where(r => r.Name == "SongCore").Count() == 1);
                Console.WriteLine(results.MainPropertyGroupElement.ToString());
            }
            else
            {
                Assert.Fail();
            }
        }
        public override bool Handle(ProjectParser project)
        {
            var changed = false;

            var root = project.RootElement;
            var propertyGroups = root.PropertyGroups;
            foreach (var propertyGroup in propertyGroups)
            {
                var projectElements = propertyGroup.AllChildren.Where(x => x is ProjectPropertyElement);
                foreach (ProjectPropertyElement propertyElement in projectElements)
                {
                    if (!propertyElement.Name.ToLower().Equals("targetframeworkversion")) continue;
                    propertyElement.Value = "v4.0";
                    changed = true;
                }
            }
            return changed;
        }
 public void BeforeEach()
 {
     Parser = new ProjectParser(SolutionContents);
 }
Beispiel #35
0
			public void TestWebFormFiles()
			{
				string data =
				@"<?xml version=""1.0"" encoding=""utf-8""?>
					<Project DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
						<ItemGroup>
							<Compile Include=""TestClass1.aspx.cs"">
								<DependentUpon>TestClass1.aspx</DependentUpon>
							</Compile>
						</ItemGroup>
						<ItemGroup>
							<Content Include=""TestClass1.aspx"" />
							<Content Include=""TestControl.ascx"" />
							<Content Include=""TestMaster.Master"" />
						</ItemGroup>
					</Project>
				";
				Mock<ClassParser> classParser = new Mock<ClassParser>();
				List<CSClass> classList = new List<CSClass>();
				var testClass1 = new CSClass()
				{
					ClassName = "TestClass1",
					NamespaceName = "Test.Test1"
				};
				classList.Add(testClass1);
				classParser.Setup(i => i.ParseFile("C:\\Test\\TestClass1.aspx.cs", It.IsAny<string>(), It.IsAny<IEnumerable<CSClass>>())).Returns(classList);

				Mock<CSWebFormParser> webFormParser =new Mock<CSWebFormParser>();
				webFormParser.Setup(i => i.ParseFile("C:\\Test\\TestClass1.aspx"))
					.Returns(new WebFormContainer { ClassFullName = "Test.Test1.TestClass1", CodeBehindFile = "TestClass1.aspx.cs", ContainerType = EnumWebFormContainerType.WebPage });
				webFormParser.Setup(i => i.ParseFile("C:\\Test\\TestControl.ascx"))
					.Returns(new WebFormContainer { ClassFullName = "Test.Test1.TestControl", CodeBehindFile = "TestControl.ascx.cs", ContainerType = EnumWebFormContainerType.UserControl });
				webFormParser.Setup(i => i.ParseFile("C:\\Test\\TestMaster.Master"))
					.Returns(new WebFormContainer { ClassFullName = "Test.Test1.TestMaster", CodeBehindFile = "TestMaster.Master.cs", ContainerType = EnumWebFormContainerType.MasterPage });

				ProjectParser parser = new ProjectParser(classParser.Object, webFormParser.Object);

				CSProjectFile project = parser.ParseString(data, "C:\\Test\\TestProject.csproj");

				Assert.AreEqual(1, project.ClassList.Count);
				Assert.AreEqual("Test.Test1.TestClass1", project.ClassList[0].ClassFullName);

				Assert.AreEqual(3, project.WebFormContainers.Count);
				Assert.AreEqual("Test.Test1.TestClass1", project.WebFormContainers[0].ClassFullName);
				Assert.AreEqual("Test.Test1.TestControl", project.WebFormContainers[1].ClassFullName);
				Assert.AreEqual("Test.Test1.TestMaster", project.WebFormContainers[2].ClassFullName);
			}
Beispiel #36
0
			public void TestEnsureFileIncludeExistingDependentNode()
			{
				string data =
				@"<?xml version=""1.0"" encoding=""utf-8""?>
					<Project DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
						<ItemGroup>
							<Compile Include=""TestDirectory\TestClass1.aspx.cs"">
							  <DependentUpon>SomethingElse.aspx</DependentUpon>
							</Compile>
						</ItemGroup>
					</Project>
				";
				ProjectParser parser = new ProjectParser();
				bool anyChange;
				string actualResult = parser.EnsureFileInclude(data, "C:\\Test\\TestProject.csproj", "C:\\Test\\TestDirectory\\TestClass1.aspx.cs", "C:\\Test\\TestDirectory\\TestClass1.aspx", out anyChange);
				Assert.IsTrue(anyChange);
				string expectedResult =
				@"<?xml version=""1.0"" encoding=""utf-8""?>
					<Project DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
						<ItemGroup>
							<Compile Include=""TestDirectory\TestClass1.aspx.cs"">
							  <DependentUpon>TestClass1.aspx</DependentUpon>
							</Compile>
						</ItemGroup>
					</Project>
				";
				this.CompareXml(expectedResult, actualResult);
			}
Beispiel #37
0
			public void TestEnsureFileIncludeInvalidProjectFile()
			{
				var data =
				@"<?xml version=""1.0"" encoding=""utf-8""?>
					<test>
					</test>
				";

				ProjectParser parser = new ProjectParser();
				bool anyChange;
				Assert.Throws(typeof(InvalidDataException), ()=>{parser.EnsureFileInclude(data, "C:\\Test\\Test.csproj", "C:\\Test\\TestFile.aspx", null, out anyChange);});
			} 
Beispiel #38
0
			public void TestRelativeDependentUponFilePath()
			{
				string data =
				@"<?xml version=""1.0"" encoding=""utf-8""?>
					<Project DefaultTargets=""Build"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
						<ItemGroup>
							<Compile Include=""TestDirectory\TestClass1.aspx.cs"">
								<DependentUpon>TestClass1.aspx</DependentUpon>
							</Compile>
							<Compile Include=""TestDirectory1\TestDirectory2\TestClass2.aspx.cs"">
								<DependentUpon>TestClass2.aspx</DependentUpon>
							</Compile>
						</ItemGroup>
						<ItemGroup>
							<Content Include=""TestDirectory\TestClass1.aspx"" />
							<Content Include=""TestDirectory1\TestDirectory2\TestClass2.aspx"" />
						</ItemGroup>
					</Project>
				";
				Mock<ClassParser> classParser = new Mock<ClassParser>();
				List<CSClass> classList = new List<CSClass>();
				var testClass1 = new CSClass()
				{
					ClassFullName = "Test.Test1.TestClass1"
				};
				var testClass2 = new CSClass()
				{
					ClassFullName = "Test.Test2.TestClass2"
				};
				classList.Add(testClass1);
				classParser.Setup(i => i.ParseFile("C:\\Test\\TestDirectory\\TestClass1.aspx.cs", It.IsAny<string>(), It.IsAny<IEnumerable<CSClass>>()))
							.Returns((string filePath, string projectPath, IEnumerable<CSClass> inputClassList) => AppendClassToList(inputClassList, testClass1));
				classParser.Setup(i => i.ParseFile("C:\\Test\\TestDirectory1\\TestDirectory2\\TestClass2.aspx.cs", It.IsAny<string>(), It.IsAny<IEnumerable<CSClass>>()))
							.Returns((string filePath, string projectPath, IEnumerable<CSClass> inputClassList) => AppendClassToList(inputClassList, testClass2));

				Mock<CSWebFormParser> webFormParser = new Mock<CSWebFormParser>();
				webFormParser.Setup(i => i.ParseFile("C:\\Test\\TestDirectory\\TestClass1.aspx"))
							.Returns(new WebFormContainer { ClassFullName = "Test.Test1.TestClass1", CodeBehindFile = "TestClass1.aspx.cs", ContainerType = EnumWebFormContainerType.WebPage });
				webFormParser.Setup(i => i.ParseFile("C:\\Test\\TestDirectory1\\TestDirectory2\\TestClass2.aspx"))
							.Returns(new WebFormContainer { ClassFullName = "Test.Test2.TestClass2", CodeBehindFile = "TestClass2.aspx.cs", ContainerType = EnumWebFormContainerType.WebPage });

				ProjectParser parser = new ProjectParser(classParser.Object, webFormParser.Object);

				CSProjectFile project = parser.ParseString(data, "C:\\Test\\TestProject.csproj");

				Assert.AreEqual(2, project.ClassList.Count);

				Assert.AreEqual("Test.Test1.TestClass1", project.ClassList[0].ClassFullName);
				Assert.AreEqual("Test.Test2.TestClass2", project.ClassList[1].ClassFullName);

				Assert.AreEqual(2, project.ClassFileDependencyList.Count);
				Assert.AreEqual("Test.Test1.TestClass1", project.ClassFileDependencyList[0].ClassFullName);
				Assert.AreEqual("TestDirectory\\TestClass1.aspx", project.ClassFileDependencyList[0].DependentUponFile);
				Assert.AreEqual("Test.Test2.TestClass2", project.ClassFileDependencyList[1].ClassFullName);
				Assert.AreEqual("TestDirectory1\\TestDirectory2\\TestClass2.aspx", project.ClassFileDependencyList[1].DependentUponFile);

				Assert.AreEqual(2, project.WebFormContainers.Count);

				Assert.AreEqual("Test.Test1.TestClass1", project.WebFormContainers[0].ClassFullName);
				Assert.AreEqual("TestClass1.aspx.cs", project.WebFormContainers[0].CodeBehindFile);
				Assert.AreEqual(EnumWebFormContainerType.WebPage, project.WebFormContainers[0].ContainerType);

				Assert.AreEqual("Test.Test2.TestClass2", project.WebFormContainers[1].ClassFullName);
				Assert.AreEqual("TestClass2.aspx.cs", project.WebFormContainers[1].CodeBehindFile);
				Assert.AreEqual(EnumWebFormContainerType.WebPage, project.WebFormContainers[1].ContainerType);
			}