public void CallKnownMethodeOnItselfWithThis() { var tmpProject = new ProjectInformation(); var tmpClass1 = Create.AddClass("Class1"); tmpProject.FillClasses(new List <ClassContainer> { tmpClass1 }); var tmpMethodeName = "compareTo"; tmpClass1.AddMethode(tmpMethodeName, new TypeContainer { Name = "void" }); var tmpMethode = tmpClass1.MethodeList[0]; tmpMethode.Code = new CodeBlock(); var tmpMethodeCall = Create.CallMethode(new CodeBlock(), tmpMethodeName); var tmpVarAccess = new VariableAccess() { Access = new ConstantValue("this"), Child = tmpMethodeCall, }; tmpMethode.Code.CodeEntries.Add(tmpVarAccess); new AnalyzerCore().LinkProjectInformation(tmpProject); tmpMethode.Name = "Blah"; Assert.AreEqual(tmpMethode, tmpMethodeCall.MethodeLink); }
public static void CreatePadTree(object o) { ValaProject p = o as ValaProject; if (o == null) { return; } ProjectInformation pi = ProjectInformationManager.Instance.Get(p); try { foreach (ProjectFile f in p.Files) { if (f.BuildAction == BuildAction.Compile) { pi.AddFile(f.FilePath); } } foreach (ProjectPackage package in p.Packages) { if (!package.IsProject) { pi.AddPackage(p.Name); } } } catch (IOException) { return; } }
public void StateManager_GetConnectedServer() { // Setup const string SharedKey = "Key"; // The key is the same for all projects on purpose ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host); var connection1 = new ConnectionInformation(new Uri("http://conn1")); var project1 = new ProjectInformation { Key = SharedKey }; var connection2 = new ConnectionInformation(new Uri("http://conn2")); var project2 = new ProjectInformation { Key = SharedKey }; testSubject.SetProjects(connection1, new ProjectInformation[] { project1 }); testSubject.SetProjects(connection2, new ProjectInformation[] { project2 }); // Case 1: Exists // Act+Verify Assert.AreEqual(connection1, testSubject.GetConnectedServer(project1)); Assert.AreEqual(connection2, testSubject.GetConnectedServer(project2)); // Case 2: Doesn't exist // Act+Verify Assert.IsNull(testSubject.GetConnectedServer(new ProjectInformation { Key = SharedKey })); }
public void StateManager_BindCommand_DynamicText() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host, section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new ProjectInformation[] { new ProjectInformation() }; testSubject.SetProjects(connection1, projects); ProjectViewModel projectVM = testSubject.ManagedState.ConnectedServers.Single().Projects.Single(); host.SetActiveSection(section); testSubject.SyncCommandFromActiveSection(); ContextualCommandViewModel bindCmd = projectVM.Commands.First(x => x.InternalRealCommand.Equals(section.BindCommand)); // Case 1: Bound projectVM.IsBound = true; // Act + Verify Assert.AreEqual(Strings.SyncButtonText, bindCmd.DisplayText, "Unexpected disabled context command text"); // Case 2: Not bound projectVM.IsBound = false; // Act + Verify Assert.AreEqual(Strings.BindButtonText, bindCmd.DisplayText, "Unexpected context command text"); }
public ParameterDataProvider(Document document, ProjectInformation info, string functionName) { this.editor = document.TextEditor; foreach (Function f in info.Functions) { if (f.Name == functionName) { functions.Add(f); } } string currentFile = document.FileName; if (info.IncludedFiles.ContainsKey(currentFile)) { foreach (FileInformation fi in info.IncludedFiles[currentFile]) { foreach (Function f in fi.Functions) { if (f.Name == functionName) { functions.Add(f); } } } } }
public override void BuildChildNodes(ITreeBuilder builder, object dataObject) { CProject p = dataObject as CProject; if (p == null) { return; } bool nestedNamespaces = builder.Options["NestedNamespaces"]; ProjectInformation info = ProjectInformationManager.Instance.Get(p); // Namespaces foreach (Namespace n in info.Namespaces) { if (nestedNamespaces) { if (n.Parent == null) { builder.AddChild(n); } } else { builder.AddChild(n); } } // Globals builder.AddChild(info.Globals); // Macro Definitions builder.AddChild(info.MacroDefinitions); }
/// <summary> /// If the given uri corresponds to a C# project file, /// determines if the project is consistent with a recognized Q# project using the ProjectLoader. /// Returns the project information containing the outputPath of the project /// along with the Q# source files as well as all project and dll references as out parameter if it is. /// Returns null if it isn't, or if the project file itself has been listed as to be ignored. /// Calls SendTelemetry with suitable data if the project is a recognized Q# project. /// </summary> internal bool QsProjectLoader(Uri projectFile, out ProjectInformation info) { info = null; if (projectFile == null || !ValidFileUri(projectFile) || IgnoreFile(projectFile)) { return(false); } var projectInstance = this.ProjectLoader.TryGetQsProjectInstance(projectFile.LocalPath, out var telemetryProps); if (projectInstance == null) { return(false); } var outputDir = projectInstance.GetPropertyValue("OutputPath"); var targetFile = projectInstance.GetPropertyValue("TargetFileName"); var outputPath = Path.Combine(projectInstance.Directory, outputDir, targetFile); var sourceFiles = GetItemsByType(projectInstance, "QsharpCompile"); var projectReferences = GetItemsByType(projectInstance, "ProjectReference"); var references = GetItemsByType(projectInstance, "Reference"); var version = projectInstance.GetPropertyValue("QsharpLangVersion"); var telemetryMeas = new Dictionary <string, int> { ["sources"] = sourceFiles.Count() }; this.SendTelemetry("project-load", telemetryProps, telemetryMeas); // does not send anything unless the corresponding flag is defined upon compilation info = new ProjectInformation(version, outputPath, sourceFiles, projectReferences, references); return(true); }
/// <summary> /// Perform constructor-specific completion /// </summary> private ValaCompletionDataList CompleteConstructor(string lineText, int line, int column) { ProjectInformation parser = Parser; Match match = initializationRegex.Match(lineText); ValaCompletionDataList list = new ValaCompletionDataList(); ThreadPool.QueueUserWorkItem(delegate { if (match.Success) { // variable initialization if (match.Groups["typename"].Success || "var" != match.Groups["typename"].Value) { // simultaneous declaration and initialization parser.GetConstructorsForType(match.Groups["typename"].Value, Document.FileName, line, column, list); } else if (match.Groups["variable"].Success) { // initialization of previously declared variable parser.GetConstructorsForExpression(match.Groups["variable"].Value, Document.FileName, line, column, list); } if (0 == list.Count) { // Fallback to known types parser.GetTypesVisibleFrom(Document.FileName, line, column, list); } } }); return(list); } // CompleteConstructor
public void CheckfoBaseErrors() { var tmpProject = new ProjectInformation(); var tmpObjectInformation = CSharpWriter.CreateClassesFromObjectInformation(tmpProject, new ConverterBase()).ToList(); Assert.AreEqual(0, tmpObjectInformation.Count); }
public BindingWorkflow(IHost host, ConnectionInformation connectionInformation, ProjectInformation project) { if (host == null) { throw new ArgumentNullException(nameof(host)); } if (connectionInformation == null) { throw new ArgumentNullException(nameof(connectionInformation)); } if (project == null) { throw new ArgumentNullException(nameof(project)); } this.host = host; this.connectionInformation = connectionInformation; this.project = project; this.projectSystem = this.host.GetService <IProjectSystemHelper>(); this.projectSystem.AssertLocalServiceIsNotNull(); this.solutionBindingOperation = new SolutionBindingOperation( this.host, this.connectionInformation, this.project.Key); }
/// <summary> /// called when the worker is supposed to start /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void DoWork(object sender, DoWorkEventArgs e) { Project activeProject = (Project)e.Argument; LoggingManager.Instance.Logger.Debug(string.Format("Project Fullname: {0}", activeProject.FullName)); //-----make sure the nuGet exe does exist if (string.IsNullOrEmpty(OptionsManager.Instance.Configuration.GeneralOptions.NuGetOptions.ExePath)) { throw new NoNuGetExecutableExceptions("nuget.exe not found in the configuration"); } PackageInformation packageInfo = null; ProjectInformation projectInformation = null; //----- prepare the project if (!_worker.CancellationPending) { _worker.ReportProgress(0, "Preparing Project..."); PreAnalyseProject(activeProject, out packageInfo, out projectInformation); } //-----analyse the project if (!_worker.CancellationPending) { _worker.ReportProgress(50, "Analysing Project..."); AnalyseProject(activeProject, packageInfo, projectInformation); } e.Cancel = _worker.CancellationPending; e.Result = packageInfo; }
public void SectionController_BrowseToProjectDashboardCommand() { // Setup var webBrowser = new ConfigurableWebBrowser(); var testSubject = this.CreateTestSubject(webBrowser); var serverUrl = new Uri("http://my-sonar-server:5555"); var connectionInfo = new ConnectionInformation(serverUrl); var projectInfo = new ProjectInformation { Key = "p1" }; Uri expectedUrl = new Uri(serverUrl, string.Format(SonarQubeServiceWrapper.ProjectDashboardRelativeUrl, projectInfo.Key)); this.sonarQubeService.RegisterProjectDashboardUrl(connectionInfo, projectInfo, expectedUrl); // Case 1: Null parameter // Act + Verify CanExecute Assert.IsFalse(testSubject.BrowseToProjectDashboardCommand.CanExecute(null)); // Case 2: Project VM var serverViewModel = new ServerViewModel(connectionInfo); var projectViewModel = new ProjectViewModel(serverViewModel, projectInfo); // Act + Verify CanExecute Assert.IsTrue(testSubject.BrowseToProjectDashboardCommand.CanExecute(projectViewModel)); // Act + Verify Execute testSubject.BrowseToProjectDashboardCommand.Execute(projectViewModel); webBrowser.AssertNavigateToCalls(1); webBrowser.AssertRequestToNavigateTo(expectedUrl.ToString()); }
public void ProjectViewModel_AutomationName() { // Arrange var projectInfo = new ProjectInformation { Key = "P1", Name = "Project1" }; var testSubject = new ProjectViewModel(CreateServerViewModel(), projectInfo); var expectedNotBound = projectInfo.Name; var expectedBound = string.Format(CultureInfo.CurrentCulture, Strings.AutomationProjectBoundDescription, projectInfo.Name); // Test case 1: bound // Act testSubject.IsBound = true; var actualBound = testSubject.AutomationName; // Assert actualBound.Should().Be(expectedBound, "Unexpected bound SonarQube project description"); // Test case 2: not bound // Act testSubject.IsBound = false; var actualNotBound = testSubject.AutomationName; // Assert actualNotBound.Should().Be(expectedNotBound, "Unexpected unbound SonarQube project description"); }
public void StateManager_ToggleShowAllProjectsCommand_DynamicText() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host, section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new ProjectInformation[] { new ProjectInformation(), new ProjectInformation() }; testSubject.SetProjects(connection1, projects); ServerViewModel serverVM = testSubject.ManagedState.ConnectedServers.Single(); host.SetActiveSection(section); testSubject.SyncCommandFromActiveSection(); ContextualCommandViewModel toggleContextCmd = serverVM.Commands.First(x => x.InternalRealCommand.Equals(section.ToggleShowAllProjectsCommand)); // Case 1: No bound projects serverVM.ShowAllProjects = true; // Act + Verify Assert.AreEqual(Strings.HideUnboundProjectsCommandText, toggleContextCmd.DisplayText, "Unexpected disabled context command text"); // Case 2: has bound projects serverVM.ShowAllProjects = false; // Act + Verify Assert.AreEqual(Strings.ShowAllProjectsCommandText, toggleContextCmd.DisplayText, "Unexpected context command text"); }
/// <summary> /// Find or Create Class for Name and Using-List /// </summary> /// <param name="inProject"></param> /// <param name="inClassName"></param> /// <param name="inPossibleNamespaces"></param> /// <returns></returns> public static ClassContainer GetClassOrUnknownForType(this ProjectInformation inProject, string inClassName, List <string> inPossibleNamespaces) { if (string.IsNullOrEmpty(inClassName)) { return(null); } var tmpClass = inProject.ClassForNameAndNamespaces(inClassName, inPossibleNamespaces); if (tmpClass != null) { return(tmpClass); } if (inProject.GetAliasType(inClassName) != null) { return(inProject.GetAliasType(inClassName)); } var tmpUnknown = inProject.UnknownClassForNameAndNamespaces(inClassName, inPossibleNamespaces); if (tmpUnknown == null) { tmpUnknown = new UnknownTypeClass(inClassName) { PossibleNamespace = inPossibleNamespaces }; inProject.AddUnknownClass(tmpUnknown); } return(tmpUnknown); }
public void Apply() { var worksetLog = new TransactionLog(@"Workset Creation/Modifications"); if (WorksharingIsEnabled) { ModelSetupWizardUtilities.ApplyWorksetModifications(doc, Worksets.ToList(), ref worksetLog); } var projectInfoLog = new TransactionLog(@"Project Information Modifications"); ModelSetupWizardUtilities.ApplyProjectInfoModifications(doc, ProjectInformation.ToList(), ref projectInfoLog); var iniFile = IniIO.GetIniFile(doc); if (iniFile.Length > 0) { IniIO.WriteColours(iniFile, Colours.ToList()); } else { SCaddinsApp.WindowManager.ShowMessageBox(iniFile + " does not exist"); } string msg = "Summary" + System.Environment.NewLine + System.Environment.NewLine + worksetLog + System.Environment.NewLine + projectInfoLog; SCaddinsApp.WindowManager.ShowMessageBox("Model Setup Wizard - Summary", msg); TryClose(true); }
} // member function constructor /// <summary> /// Create a ParameterDataProvider for a constructor /// </summary> /// <param name="constructorOverload"> /// A <see cref="System.String"/>: The named of the pertinent constructor overload /// </param> public ParameterDataProvider(Document document, ProjectInformation info, string typename, string constructorOverload) { this.functionName = constructorOverload; this.editor = document.TextEditor; this.info = info; List <Symbol> myfunctions = info.GetConstructorsForType(typename, document.FileName, editor.CursorLine, editor.CursorColumn, null); // bottleneck if (1 < myfunctions.Count) { foreach (Symbol function in myfunctions) { if (functionName.Equals(function.Name, StringComparison.Ordinal)) { functions = new List <Symbol> () { function }; return; } } } functions = myfunctions; } // constructor constructor
public override Task <MonoDevelop.Ide.CodeCompletion.ParameterHintingResult> HandleParameterCompletionAsync(CodeCompletionContext completionContext, char completionChar, CancellationToken token = default(CancellationToken)) { if (completionChar != '(') { return(null); } CProject project = DocumentContext.Project as CProject; if (project == null) { return(Task.FromResult <MonoDevelop.Ide.CodeCompletion.ParameterHintingResult> (null)); } ProjectInformation info = ProjectInformationManager.Instance.Get(project); string lineText = Editor.GetLineText(Editor.CaretLine).TrimEnd(); if (lineText.EndsWith(completionChar.ToString(), StringComparison.Ordinal)) { lineText = lineText.Remove(lineText.Length - 1).TrimEnd(); } int nameStart = lineText.LastIndexOfAny(allowedChars); nameStart++; string functionName = lineText.Substring(nameStart).Trim(); if (string.IsNullOrEmpty(functionName)) { return(Task.FromResult <MonoDevelop.Ide.CodeCompletion.ParameterHintingResult> (null)); } return(Task.FromResult((MonoDevelop.Ide.CodeCompletion.ParameterHintingResult) new ParameterDataProvider(nameStart, Editor, info, functionName))); }
public ParameterDataProvider(int startOffset, TextEditor editor, ProjectInformation info, string functionName) : base(startOffset) { this.editor = editor; foreach (Function f in info.Functions) { if (f.Name == functionName) { data.Add(new DataWrapper(f)); } } string currentFile = editor.FileName; if (info.IncludedFiles.ContainsKey(currentFile)) { foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFile]) { foreach (Function f in fi.Functions) { if (f.Name == functionName) { data.Add(new DataWrapper(f)); } } } } }
public void RefreshView() { if (!dataGridView1.Visible) { return; } Trace.TraceInformation("Refreshing NUnit View."); DTE dte = (DTE)Package.GetGlobalService(typeof(DTE)); DataTable table = new DataTable(); table.Columns.Add(new DataColumn("Success", typeof(TestState))); table.Columns.Add(new DataColumn("Namespace", typeof(string))); table.Columns.Add(new DataColumn("Case", typeof(string))); table.Columns.Add(new DataColumn("Test", typeof(string))); table.Columns.Add(new DataColumn("Time", typeof(string))); table.Columns.Add(new DataColumn("Message", typeof(string))); table.Columns.Add(new DataColumn("TestInformation", typeof(TestInformation))); foreach (Project project in dte.Solution) { AddProject(project); } dataGridView1.DataSource = table; if ((projectsToLoad.Count > 0) && !testListWorker.IsBusy) { currentlyLoadingProject = projectsToLoad.Dequeue(); testListWorker.RunWorkerAsync(); } }
public void BindingController_BindCommand_Execution() { // Arrange BindingController testSubject = this.PrepareCommandForExecution(); // Act var projectToBind1 = new ProjectInformation { Key = "1" }; ProjectViewModel projectVM1 = CreateProjectViewModel(projectToBind1); testSubject.BindCommand.Execute(projectVM1); // Assert this.workflow.BoundProject.Should().Be(projectToBind1); // Act, bind a different project var projectToBind2 = new ProjectInformation { Key = "2" }; ProjectViewModel projectVM2 = CreateProjectViewModel(projectToBind2); testSubject.BindCommand.Execute(projectVM2); // Assert this.workflow.BoundProject.Should().Be(projectToBind2); }
private void loadBtn_Click(object sender, EventArgs e) { var loadFolderPath = new FolderSelectDialog(); var doc = new XmlDocument(); if (loadFolderPath.ShowDialog()) { var externalProjectsBindingList = new BindingList <ProjectDetails>(); _areExternalStudioProjects = true; _languages.Clear(); _projectsDataSource.Clear(); var projectsPathList = Directory.GetFiles(loadFolderPath.FileName, "*.sdlproj", SearchOption.AllDirectories); foreach (var projectPath in projectsPathList) { var reportFolderPath = Path.Combine(projectPath.Substring(0, projectPath.LastIndexOf(@"\", StringComparison.Ordinal)), "Reports"); if (Help.ReportFileExist(reportFolderPath)) { var projectDetails = ProjectInformation.GetExternalProjectDetails(projectPath); doc.Load(projectDetails.ProjectPath); Help.LoadReports(doc, projectDetails.ProjectFolderPath, projectDetails); externalProjectsBindingList.Add(projectDetails); } } foreach (var item in externalProjectsBindingList) { _projectsDataSource.Add(item); } projListbox.DataSource = _projectsDataSource; RefreshProjectsListBox(); RefreshLanguageListbox(); } }
private void SonarQubeServiceWrapper_TryGetExportProfile(Language language) { using (var testSubject = new TestableSonarQubeServiceWrapper(this.serviceProvider)) { // Setup QualityProfile profile = CreateRandomQualityProfile(language); var project = new ProjectInformation { Key = "awesome1", Name = "My Awesome Project" }; var expectedExport = RoslynExportProfileHelper.CreateExport(ruleSet: TestRuleSetHelper.CreateTestRuleSet(3)); var roslynExporter = SonarQubeServiceWrapper.CreateRoslynExporterName(language); ConnectionInformation conn = ConfigureValidConnection(testSubject, new[] { project }); // Setup test server RegisterProfileExportQueryValidator(testSubject); RequestHandler getExportHandler = testSubject.RegisterRequestHandler( SonarQubeServiceWrapper.CreateQualityProfileExportUrl(profile, language, roslynExporter), ctx => ServiceProfileExport(ctx, expectedExport) ); // Act RoslynExportProfile actualExport; Assert.IsTrue(testSubject.TryGetExportProfile(conn, profile, language, CancellationToken.None, out actualExport), "TryGetExportProfile failed unexpectedly"); // Verify Assert.IsNotNull(actualExport, "Expected a profile export to be returned"); RoslynExportProfileHelper.AssertAreEqual(expectedExport, actualExport); getExportHandler.AssertHandlerCalled(1); } }
private void OnBindingFinished(ProjectInformation projectInformation, bool isFinishedSuccessfully) { this.IsBindingInProgress = false; this.host.VisualStateManager.ClearBoundProject(); if (isFinishedSuccessfully) { this.host.VisualStateManager.SetBoundProject(projectInformation); var conflictsController = this.host.GetService <IRuleSetConflictsController>(); conflictsController.AssertLocalServiceIsNotNull(); if (conflictsController.CheckForConflicts()) { // In some cases we will end up navigating to the solution explorer, this will make sure that // we're back in team explorer to view the conflicts this.ServiceProvider.GetMefService <ITeamExplorerController>()?.ShowSonarQubePage(); } else { VsShellUtils.ActivateSolutionExplorer(this.ServiceProvider); } } else { IUserNotification notifications = this.host.ActiveSection?.UserNotifications; if (notifications != null) { // Create a command with a fixed argument with the help of ContextualCommandViewModel that creates proxy command for the contextual (fixed) instance and the passed in ICommand that expects it ICommand rebindCommand = new ContextualCommandViewModel(projectInformation, new RelayCommand <ProjectInformation>(this.OnBind, this.OnBindStatus)).Command; notifications.ShowNotificationError(Strings.FailedToToBindSolution, NotificationIds.FailedToBindId, rebindCommand); } } }
public ParameterDataProvider(int startOffset, Document document, ProjectInformation info, string functionName) : base(startOffset) { this.editor = document.Editor; foreach (Function f in info.Functions) { if (f.Name == functionName) { functions.Add(f); } } string currentFile = document.FileName; if (info.IncludedFiles.ContainsKey(currentFile)) { foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFile]) { foreach (Function f in fi.Functions) { if (f.Name == functionName) { functions.Add(f); } } } } }
public void SectionController_BrowseToProjectDashboardCommand() { // Arrange var webBrowser = new ConfigurableWebBrowser(); var testSubject = this.CreateTestSubject(webBrowser); var serverUrl = new Uri("http://my-sonar-server:5555"); var connectionInfo = new ConnectionInformation(serverUrl); var projectInfo = new ProjectInformation { Key = "p1" }; Uri expectedUrl = new Uri(serverUrl, string.Format(SonarQubeServiceWrapper.ProjectDashboardRelativeUrl, projectInfo.Key)); this.sonarQubeService.RegisterProjectDashboardUrl(connectionInfo, projectInfo, expectedUrl); // Case 1: Null parameter // Act + Assert CanExecute testSubject.BrowseToProjectDashboardCommand.CanExecute(null).Should().BeFalse(); // Case 2: Project VM var serverViewModel = new ServerViewModel(connectionInfo); var projectViewModel = new ProjectViewModel(serverViewModel, projectInfo); // Act + Assert CanExecute testSubject.BrowseToProjectDashboardCommand.CanExecute(projectViewModel).Should().BeTrue(); // Act + Assert Execute testSubject.BrowseToProjectDashboardCommand.Execute(projectViewModel); webBrowser.NavigatedUrls.Should().HaveCount(1); webBrowser.NavigatedUrls.Should().Contain(expectedUrl.ToString()); }
void CSharpCreateModelsFromOpenApiJson(string json) { CreateFolder(FilePath + "/" + SAVE_FOLDER_NAME); Dictionary <string, object> dict = Json.Deserialize(json) as Dictionary <string, object>; if (!dict.ContainsKey("components")) { //コンポーネント定義がない場合は生成を行わない return; } var componentsDict = (Dictionary <string, object>)dict["components"]; var schemasDict = (Dictionary <string, object>)componentsDict["schemas"]; ProjectInformation projectInformation = GetProjectlInfoFromOpenApiModel(dict); var infoDict = (Dictionary <string, object>)dict["info"]; string titleText = ((string)infoDict["title"]).Replace(" ", "").Replace(" ", ""); foreach (var model in schemasDict) { var modelInfo = GetModelInfoFromOpenApiModel(model); CreateCSharpCodeModel(FilePath + "/" + SAVE_FOLDER_NAME, modelInfo, createInteraface); CreateDatastore(FilePath + "/" + SAVE_FOLDER_NAME, modelInfo); var guid = CreateDatastoreScriptMetaAndGUID(FilePath + "/" + SAVE_FOLDER_NAME, modelInfo); CreateDatastoreAsset(FilePath + "/" + SAVE_FOLDER_NAME, modelInfo, guid); CreateRepository(FilePath + "/" + SAVE_FOLDER_NAME, schemasDict.ToList().Select(o => GetModelInfoFromOpenApiModel(o)), projectInformation); var repositoryGuid = CreateRepositoryScriptMetaAndGUID(FilePath + "/" + SAVE_FOLDER_NAME, titleText); CreateRepositoryAsset(FilePath + "/" + SAVE_FOLDER_NAME, titleText, repositoryGuid); if (createInteraface) { CreateCSharpCodeInterface(FilePath + "/" + SAVE_FOLDER_NAME, modelInfo); CreateControllerInterface(FilePath + "/" + SAVE_FOLDER_NAME, projectInformation); } CreateController(FilePath + "/" + SAVE_FOLDER_NAME, projectInformation); } }
public async Task SonarQubeServiceWrapper_DownloadQualityProfile_ProjectWithAnalysis() { using (var testSubject = new TestableSonarQubeServiceWrapper(this.serviceProvider)) { // Setup HttpClient httpClient = testSubject.CreateHttpClient(); var language = Language.CSharp; QualityProfile expectedProfile = CreateRandomQualityProfile(language); var project = new ProjectInformation { Key = "awesome1", Name = "My Awesome Project" }; ConfigureValidConnection(testSubject, new[] { project }); // Setup test server RegisterQualityProfileQueryValidator(testSubject); RequestHandler handler = testSubject.RegisterRequestHandler( SonarQubeServiceWrapper.CreateQualityProfileUrl(language, project), ctx => ServiceQualityProfiles(ctx, new[] { expectedProfile }) ); // Act QualityProfile actualProfile = await SonarQubeServiceWrapper.DownloadQualityProfile(httpClient, project, language, CancellationToken.None); // Verify Assert.IsNotNull(actualProfile, "Expected a quality profile"); Assert.AreEqual(expectedProfile.Key, actualProfile.Key, "Unexpected quality profile returned"); handler.AssertHandlerCalled(1); } }
public bool List(ProjectInformation project) { var result = FindProgram(project); if (result == null) { return(false); } var lines = GetLines(result); var table = new Table { ShowHeaders = false, Border = TableBorder.Rounded }; table.AddColumn(new TableColumn(string.Empty) { NoWrap = true }); table.AddColumn(string.Empty); var lineNumber = 1; foreach (var line in lines) { table.AddRow($"[grey]{lineNumber}[/]", line); lineNumber++; } AnsiConsole.WriteLine(); AnsiConsole.Write(table); return(true); }
public void ProjectViewModel_ToolTipProjectName_RespectsIsBound() { // Arrange var projectInfo = new ProjectInformation { Key = "P1", Name = "Project1" }; var viewModel = new ProjectViewModel(CreateServerViewModel(), projectInfo); // Test Case 1: When project is bound, should show message with 'bound' marker // Act viewModel.IsBound = true; // Assert StringAssert.Contains(viewModel.ToolTipProjectName, viewModel.ProjectName, "ToolTip message should include the project name"); viewModel.ToolTipProjectName.Should().NotBe(viewModel.ProjectName, "ToolTip message should also indicate that the project is 'bound'"); // Test Case 2: When project is NOT bound, should show project name only // Act viewModel.IsBound = false; // Assert viewModel.ToolTipProjectName.Should().Be(viewModel.ProjectName, "ToolTip message should be exactly the same as the project name"); }
public static ProjectModel GetModel(string path) { var project = GetProject(path); if (project == null) { throw new InvalidOperationException("There's no project.json here"); } var model = new ProjectModel(); var sourcesProjectWideSources = project.Files.SourceFiles.ToList(); foreach (var framework in project.GetTargetFrameworks()) { var dependencySources = new List<string>(sourcesProjectWideSources); var dependencyInfo = ResolveDependencyInfo(project, framework.FrameworkName); // Add shared files from projects foreach (var reference in dependencyInfo.ProjectReferences) { // Only add direct dependencies as sources if (!project.Dependencies.Any(d => string.Equals(d.Name, reference.Name, StringComparison.OrdinalIgnoreCase))) { continue; } dependencySources.AddRange(reference.Project.Files.SharedFiles); } dependencySources.AddRange(dependencyInfo.ExportedSourcesFiles); var projectInfo = new ProjectInformation() { Path = project.ProjectFilePath, Project = project, Configuration = "Debug", Framework = framework.FrameworkName, SourceFiles = dependencySources, DependencyInfo = dependencyInfo, CompilationSettings = project.GetCompilerOptions(framework.FrameworkName, "Debug") .ToCompilationSettings(framework.FrameworkName) }; model.Projects.Add(framework.FrameworkName, projectInfo); } return model; }
private ProjectId AddProject(ProjectInformation project) { // Create the framework specific project and add it to the workspace var projectInfo = ProjectInfo.Create( ProjectId.CreateNewId(), VersionStamp.Create(), project.Project.Name + "+" + project.Framework, project.Project.Name, LanguageNames.CSharp, project.Path); OnProjectAdded(projectInfo); OnParseOptionsChanged(projectInfo.Id, new CSharpParseOptions(project.CompilationSettings.LanguageVersion, preprocessorSymbols: project.CompilationSettings.Defines)); OnCompilationOptionsChanged(projectInfo.Id, project.CompilationSettings.CompilationOptions); foreach (var file in project.SourceFiles) { using (var stream = File.OpenRead(file)) { var sourceText = SourceText.From(stream, encoding: Encoding.UTF8); var id = DocumentId.CreateNewId(projectInfo.Id); var version = VersionStamp.Create(); var loader = TextLoader.From(TextAndVersion.Create(sourceText, version)); OnDocumentAdded(DocumentInfo.Create(id, file, filePath: file, loader: loader)); } } foreach (var path in project.DependencyInfo.References) { OnMetadataReferenceAdded(projectInfo.Id, GetMetadataReference(path)); } foreach (var reference in project.DependencyInfo.ProjectReferences) { var pe = ProjectModel.GetModel(reference.Path); // This being null would me a broken project reference var projectReference = pe.Projects[reference.Framework]; var id = AddProject(projectReference); OnProjectReferenceAdded(projectInfo.Id, new Microsoft.CodeAnalysis.ProjectReference(id)); } return projectInfo.Id; }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { try { if (cbPackageName.SelectedIndex == -1 || cbPackageName.SelectedIndex == 0) MessageBox.Show("Package name is mandatory."); else { if (!Directory.Exists(ConfigurationManager.AppSettings["XmlDestination"] + "/" + cbPackageName.SelectedValue.ToString())) // if it doesn't exist, create Directory.CreateDirectory(ConfigurationManager.AppSettings["XmlDestination"] + "/" + cbPackageName.SelectedValue.ToString()); File.WriteAllText(XmlFile, XmlUtilities.GetFormatedXml(fullXml)); PermanentStoreFiles(); DropExistingItems(); CAHarvestUtilities harvest = new CAHarvestUtilities(UserName, Password, Broker); ProjectInformation projectInfo = new ProjectInformation(); projectInfo.Backport = ((cbBackport.SelectedIndex != 0 && cbBackport.SelectedIndex != -1) ? cbBackport.SelectedValue.ToString() : ""); projectInfo.PackageName = cbPackageName.SelectedValue.ToString(); projectInfo.ProdDate = (string.IsNullOrEmpty(txbReleaseDate.Text) ? null : (DateTime?)Convert.ToDateTime(txbReleaseDate.Text)); projectInfo.DevCompleteDate = (string.IsNullOrEmpty(txbDevComplete.Text) ? null : (DateTime?)Convert.ToDateTime(txbDevComplete.Text)); ; harvest.SaveProjectComments(cbPackageName.SelectedValue.ToString(), Repository, projectInfo); MessageBox.Show("Data successfully committed."); } } catch (Exception ex) { MessageBox.Show("There was an error creating the XML: " + ex.Message); } }
public static ProjectInformation GetProjectInfoFromXml(XElement xmlInformation) { ProjectInformation projectInfo = new ProjectInformation(); projectInfo.PackageName = xmlInformation.Element("PackageName").Value; projectInfo.ProdDate = (xmlInformation.Element("ProdReleaseDate") == null ? null : (DateTime?)Convert.ToDateTime(xmlInformation.Element("ProdReleaseDate").Value)); projectInfo.DevCompleteDate = (xmlInformation.Element("ProdReleaseDate") == null ? null : (DateTime?)Convert.ToDateTime(xmlInformation.Element("ProdReleaseDate").Value)); projectInfo.Backport = (xmlInformation.Element("BackportPackage") == null ? null : xmlInformation.Element("BackportPackage").Value); /*var xmlResult = from pi in xmlInformation select new ProjectInformation { PackageName = pi.Element("PackageName").Value, ProdDate = (pi.Element("ProdReleaseDate") == null ? null : (DateTime?)Convert.ToDateTime(pi.Element("ProdReleaseDate").Value)), DevCompleteDate = (pi.Element("DevCompleteDate") == null ? null : (DateTime?)Convert.ToDateTime(pi.Element("DevCompleteDate").Value)), Backport = pi.Element("BackportPackage").Value }; projectInfo = xmlResult.FirstOrDefault();*/ return projectInfo; }
public void SaveProjectComments(string packageName, string projectName, ProjectInformation projectInfo) { string ApplicationPath = ConfigurationManager.AppSettings["HarvestAPIFolder"] + "hup.exe"; string ApplicationArguments = "-b " + Broker + " -p \"" + packageName + "\"" + " -en \"" + projectName + "\"" + " -usr " + UserName + " -pw " + Password + " -nt \"" + @"************* READ ONLY BLOCK *************" + (projectInfo.DevCompleteDate == null ? "" : Environment.NewLine + "Dev Complete date: " + ((DateTime)projectInfo.DevCompleteDate).ToShortDateString()) + (projectInfo.ProdDate == null ? "" : Environment.NewLine + "Production release date: " + ((DateTime)projectInfo.ProdDate).ToShortDateString()) + (projectInfo.Backport == "-- Choose an item --" ? "" : Environment.NewLine + "Backport: " + projectInfo.Backport) + "************* Updated by " + UserName + " on " + DateTime.Now.ToShortDateString() + "\""; ; Process ProcessObj = new Process(); // StartInfo contains the startup information of // the new process ProcessObj.StartInfo.FileName = ApplicationPath; ProcessObj.StartInfo.Arguments = ApplicationArguments; // These two optional flags ensure that no DOS window // appears ProcessObj.StartInfo.UseShellExecute = false; ProcessObj.StartInfo.CreateNoWindow = true; // If this option is set the DOS window appears again :-/ // ProcessObj.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; // This ensures that you get the output from the DOS application ProcessObj.StartInfo.RedirectStandardOutput = true; // Start the process ProcessObj.Start(); // Wait that the process exits ProcessObj.WaitForExit(); // Now read the output of the DOS application string Result = ProcessObj.StandardOutput.ReadToEnd(); //string logPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\log.txt"; //File.WriteAllText(logPath, Result); Log.Debug("SaveProjectComments - ApplicationPath - " + ApplicationPath); Log.Debug("SaveProjectComments - ApplicationArguments - " + ApplicationArguments); Log.Debug("SaveProjectComments - CMD Line result - " + Result); }
private DbContextItemTemplateWizard CreateView( DbContextItemTemplateWizardViewModel model, IVsUIShell shell ) { Contract.Requires( model != null ); Contract.Requires( shell != null ); Contract.Ensures( Contract.Result<DbContextItemTemplateWizard>() != null ); var projectInfo = new ProjectInformation( Project ); var dataConnectionDialogFactory = new Lazy<IVsDataConnectionDialogFactory>( Context.GetRequiredService<IVsDataConnectionDialogFactory> ); var dataExplorerConnectionManager = new Lazy<IVsDataExplorerConnectionManager>( Context.GetRequiredService<IVsDataExplorerConnectionManager> ); return new DbContextItemTemplateWizard( model, projectInfo, shell, dataConnectionDialogFactory, dataExplorerConnectionManager ); }