public void CheckOldResourceDesignerWithWrongCasingIsRemoved(bool isRelease, ProjectLanguage language) { var proj = new XamarinAndroidApplicationProject() { Language = language, IsRelease = isRelease, }; proj.SetProperty("AndroidUseIntermediateDesignerFile", "True"); proj.SetProperty("AndroidResgenFile", "Resources\\Resource.Designer" + proj.Language.DefaultExtension); using (var b = CreateApkBuilder("temp/CheckOldResourceDesignerWithWrongCasingIsRemoved")) { var designer = proj.Sources.First(x => x.Include() == "Resources\\Resource.designer" + proj.Language.DefaultExtension); designer.Deleted = true; Assert.IsTrue(b.Build(proj), "Build should have succeeded."); Assert.IsFalse(File.Exists(Path.Combine(b.ProjectDirectory, "Resources", "Resource.designer" + proj.Language.DefaultExtension)), "{0} should not exists", designer.Include()); var outputFile = Path.Combine(Root, b.ProjectDirectory, proj.IntermediateOutputPath, "Resource.Designer" + proj.Language.DefaultExtension); Assert.IsTrue(File.Exists(outputFile), "Resource.Designer{1} should have been created in {0}", proj.IntermediateOutputPath, proj.Language.DefaultExtension); Assert.IsTrue(b.Clean(proj), "Clean should have succeeded."); Assert.IsFalse(File.Exists(outputFile), "Resource.Designer{1} should have been cleaned in {0}", proj.IntermediateOutputPath, proj.Language.DefaultExtension); } }
/// <summary> /// Create a new project using specified info /// </summary> /// <param name="dte">dte instance</param> /// <param name="projectName">project name</param> /// <param name="kind">project kind</param> /// <param name="language">project language</param> /// <returns>new created project</returns> public static Project CreateProject( this DTE dte, string solutionPath, string projectName, ProjectKind kind, ProjectLanguage language) { Debug.Assert(dte != null, "CreateProject: Dte is null"); Debug.Assert(!string.IsNullOrEmpty(solutionPath), "!string.IsNullOrEmpty(solutionPath)"); Debug.Assert(!string.IsNullOrEmpty(projectName), "!string.IsNullOrEmpty(projectName)"); Debug.Assert(dte.Solution != null, "CreateProject: dte.Solution must be created by adding project"); var template = GetProjectTemplate(dte, kind, language); // Check if the project directory exists delete it does since AddFromTemplate will throw if the directory exists. var projectDir = Path.Combine(solutionPath, projectName); if (Directory.Exists(projectDir)) { Directory.Delete(projectDir, true); } dte.Solution.AddFromTemplate(template, Path.Combine(solutionPath, projectName), projectName, false); foreach (Project project in dte.Solution.Projects) { if (project.Name.Contains(projectName)) // Venus projects Name is the full path name - so need to use Contains() { return(project); } } Debug.Fail("There is no new project created."); return(null); }
/// <summary> /// Create .net project /// </summary> /// <param name="type"></param> /// <param name="lang"></param> /// <param name="name"></param> /// <param name="dir"></param> /// <param name="framework"></param> public ResultLog CreateProject(ProjectType type, ProjectLanguage lang, string name, string dir, ProjectFramework framework = ProjectFramework.Default) { string typeStr = ProjectTypeAsStr(type); string frameworkStr = String.Empty; string langStr = "--language " + LanguageAsStr(lang); string nameStr = "--name " + InQuotes(name); string outputStr = "--output " + InQuotes(dir); //framework arg if (framework != ProjectFramework.Default && ( typeStr == "classlib" || typeStr == "web" || typeStr == "wpf" || typeStr == "console")) { frameworkStr = "--framework " + FrameworkAsStr(framework); } string cmd = "dotnet new " + typeStr + " " + nameStr + " " + outputStr + " " + langStr; if (frameworkStr != String.Empty) { cmd += " " + frameworkStr; } //execute return(new ResultLog(Caller.ExecuteCommand(cmd))); }
public static string GenerateAppProject(UnifiedTestConfig config) { ProjectLanguage language = config.FSharp ? ProjectLanguage.FSharp : ProjectLanguage.CSharp; ProjectFlavor flavor = config.XM45 ? ProjectFlavor.FullXM : ProjectFlavor.ModernXM; TemplateInfo info; if (!string.IsNullOrEmpty(config.ProjectName)) { info = TemplateInfo.FromCustomProject(ProjectType.App, language, config.ProjectName); } else { info = new TemplateInfo(flavor, ProjectType.App, language); config.ProjectName = info.ProjectName; } var engine = new MacAppTemplateEngine(info); var fileSubstitutions = new FileSubstitutions { TestCode = config.TestCode, TestDecl = config.TestDecl, }; PListSubstitutions pListSubstitutions = new PListSubstitutions() { Replacements = config.PlistReplaceStrings }; return(engine.Generate(config.TmpDir, CreateDefaultSubstitutions(config), fileSubstitutions, pListSubstitutions)); }
/// <summary> /// This function is used to verify if the specified text is a valid identifier in the specified language. /// </summary> /// <param name="text">The text to be validated.</param> /// <param name="projectLanguage">The project language.</param> /// <returns><see langword="null"/> if the specified text is a valid identifier in the specified language; otherwise, /// an error message.</returns> public static string GetErrorIfInvalidIdentifier(string text, ProjectLanguage projectLanguage) { if (String.IsNullOrEmpty(text)) { return Resources.InvalidIdentifierEmpty; } if (text.IndexOfAny(_invalidCharacters) >= 0) { return String.Format(CultureInfo.CurrentCulture, Resources.InvalidIdentifierCharacters, String.Join(" ", DisplayInvalidCharacters)); } if (text.Any(c => (Char.IsWhiteSpace(c)))) { return Resources.InvalidIdentifierWhitespaces; } CodeDomProvider provider = GenerateCodeDomProvider(projectLanguage); Contract.Assert(provider != null); if (!provider.IsValidIdentifier(text)) { return Resources.InvalidIdentifierReservedName; } return null; }
private static void SetLanguage(IImmutableSet <string> ids, ProjectLanguage language) { foreach (var id in ids) { _languages[id] = language; } }
private void SelectLayout(object unused) { string filter; ProjectLanguage language = Model.ActiveProject.GetCodeLanguage(); if (language == ProjectLanguage.CSharp) { filter = Resources.MasterPageCsHtmlFilter; } else if (language == ProjectLanguage.VisualBasic) { filter = Resources.MasterPageVbHtmlFilter; } else { Contract.Assert(false, "We shouldn't get here, this project's language is not supported."); return; } string file; if (DialogHost.TrySelectFile( Model.ActiveProject, Resources.LayoutPageSelectorHeading, filter, SavedSettingsKeys.LayoutPageFileKey, out file)) { LayoutPageFile = file; } }
/// <summary> /// This function is used to verify if the specified text is a valid identifier in the specified language. /// </summary> /// <param name="text">The text to be validated.</param> /// <param name="projectLanguage">The project language.</param> /// <returns><see langword="null"/> if the specified text is a valid identifier in the specified language; otherwise, /// an error message.</returns> public static string GetErrorIfInvalidIdentifier(string text, ProjectLanguage projectLanguage) { if (String.IsNullOrEmpty(text)) { return(Resources.InvalidIdentifierEmpty); } if (text.IndexOfAny(_invalidCharacters) >= 0) { return(String.Format(CultureInfo.CurrentCulture, Resources.InvalidIdentifierCharacters, String.Join(" ", DisplayInvalidCharacters))); } if (text.Any(c => (Char.IsWhiteSpace(c)))) { return(Resources.InvalidIdentifierWhitespaces); } CodeDomProvider provider = GenerateCodeDomProvider(projectLanguage); Contract.Assert(provider != null); if (!provider.IsValidIdentifier(text)) { return(Resources.InvalidIdentifierReservedName); } return(null); }
protected override bool UpgradeProject(IProjectStore projectStore, ConversionType initialVersion, ConversionType targetVersion) { ProjectLanguage projectLanguage = ProjectStoreHelper.GetProjectLanguage(projectStore); if (projectLanguage != ProjectLanguage.CSharp && projectLanguage != ProjectLanguage.VisualBasic) { return(false); } if (targetVersion != ConversionType.WebAppProject10) { return(false); } string[] array = projectStore.ProjectImports.ToArray <string>(); for (int i = 0; i < (int)array.Length; i++) { string str = array[i]; if (WebProjectConverter.webApplicationTargetVersion.Match(str).Success&& !projectStore.ChangeImport(str, "$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v10.0\\WebApplications\\Microsoft.WebApplication.targets")) { return(false); } } if (!projectStore.SetStoreVersion(CommonVersions.Version4_0)) { return(false); } return(true); }
public async Task AssignCategoryAsync(AssignRequest assignRequest) { switch (assignRequest.CategoryType) { case Project.LanguageCategory: var language = await context.Languages.FirstOrDefaultAsync(l => l.Name == assignRequest.Name); if (language == null) { language = new Language { Name = assignRequest.Name }; context.Languages.Add(language); await context.SaveChangesAsync(); } var lc = new ProjectLanguage { ProjectId = assignRequest.ProjectId, LanguageId = language.Id }; context.ProjectLanguages.Add(lc); await context.SaveChangesAsync(); break; default: break; } }
public static bool DoesLanguageSupportXaml(ProjectLanguage projectLanguage) { if (projectLanguage == ProjectLanguage.CSharp) { return(true); } return(projectLanguage == ProjectLanguage.VisualBasic); }
public static Scanner GetScanner(ProjectLanguage projectLanguage = ProjectLanguage.CSharp) { switch (projectLanguage) { case ProjectLanguage.CSharp: default: return(new CSharpScanner()); } }
private bool IsFileValid(string file, string expectedLanguage, string unExpectedLanguage) { var expectedProjectLanguage = expectedLanguage; expectedLanguage = expectedLanguage == "C#" ? "cs" : expectedLanguage; unExpectedLanguage = unExpectedLanguage == "C#" ? "cs" : unExpectedLanguage; return (ProjectLanguage.Equals(expectedProjectLanguage, StringComparison.OrdinalIgnoreCase)) && (file.Split('/').Any(x => x.Equals(ProjectLanguage, StringComparison.OrdinalIgnoreCase)) || !file.Split('/').Any(x => x.Equals(unExpectedLanguage, StringComparison.OrdinalIgnoreCase))); }
public void Create(ProjectLanguageDTO projectLang) { var newProjLang = new ProjectLanguage { Project = projectLang.Project, Language = projectLang.Language }; _db.ProjectLanguages.Add(newProjLang); _db.SaveChanges(); }
private void SelectLayout(object unused) { string masterPageVbHtmlFilter; string str; ProjectLanguage codeLanguage = ProjectExtensions.GetCodeLanguage(this.Model.ActiveProject); masterPageVbHtmlFilter = ResourcesExt.MasterPageCsHtmlFilter; if (this.DialogHost.TrySelectFile(this.Model.ActiveProject, ResourcesExt.LayoutPageSelectorHeading, masterPageVbHtmlFilter, "WebStackScaffolding_LayoutPageFile", out str)) { this.LayoutPageFile = str; } }
private static SortedSet <string> CreateHashSetBasedOnCodeLanguage(ProjectLanguage projectLanguage) { if ((object)projectLanguage == (object)ProjectLanguage.CSharp) { return(new SortedSet <string>(StringComparer.Ordinal)); } if ((object)projectLanguage != (object)ProjectLanguage.VisualBasic) { throw new InvalidOperationException("The project language is not supported."); } return(new SortedSet <string>(StringComparer.OrdinalIgnoreCase)); }
public static CodeDomProvider GenerateCodeDomProvider(ProjectLanguage projectLanguage) { if (projectLanguage == null) { throw new ArgumentNullException("projectLanguage"); } if (!CodeDomProvider.IsDefinedLanguage(projectLanguage.ToString())) { throw new InvalidOperationException("The project language is not supported."); } return(CodeDomProvider.CreateProvider(projectLanguage.ToString())); }
private void SelectLayout(object unused) { string masterPageVbHtmlFilter; string str; ProjectLanguage codeLanguage = ProjectExtensions.GetCodeLanguage(this.Model.ActiveProject); masterPageVbHtmlFilter = "Layout Pages (*.cshtml)|*.cshtml"; if (this.DialogHost.TrySelectFile(this.Model.ActiveProject, "Select a Layout Page", masterPageVbHtmlFilter, "WebStackScaffolding_LayoutPageFile", out str)) { this.LayoutPageFile = str; } }
public override IEnumerable <ITemplateScopePoint> ProvideScopePoints(TemplateAcceptanceContext context) { IProject project = context.GetProject(); if (project != null && project.IsProjectReferencingNancyRazorViewEngine()) { ProjectLanguage lang = project.ProjectProperties.DefaultLanguage; if (lang == ProjectLanguage.CSHARP) { yield return(new InRazorCSharpProject()); } } }
private static SortedSet <String> CreateHashSetBasedOnCodeLanguage(ProjectLanguage projectLanguage) { if (projectLanguage == ProjectLanguage.CSharp) { return(new SortedSet <string>(StringComparer.Ordinal)); } else if (projectLanguage == ProjectLanguage.VisualBasic) { return(new SortedSet <string>(StringComparer.OrdinalIgnoreCase)); } throw new InvalidOperationException(Resources.ScaffoldLanguageNotSupported); }
public static CodeDomProvider GenerateCodeDomProvider(ProjectLanguage projectLanguage) { if (projectLanguage == null) { throw new ArgumentNullException("projectLanguage"); } if (!CodeDomProvider.IsDefinedLanguage(projectLanguage.ToString())) { throw new InvalidOperationException(Resources.ScaffoldLanguageNotSupported); } return CodeDomProvider.CreateProvider(projectLanguage.ToString()); }
public static bool IsKnownLanguage(ProjectLanguage projectLanguage) { switch (projectLanguage) { case ProjectLanguage.CPlusPlus: case ProjectLanguage.CSharp: case ProjectLanguage.FSharp: case ProjectLanguage.VisualBasic: { return(true); } } return(false); }
public static CodeDomProvider GenerateCodeDomProvider(ProjectLanguage projectLanguage) { if (projectLanguage == null) { throw new ArgumentNullException("projectLanguage"); } if (!CodeDomProvider.IsDefinedLanguage(projectLanguage.ToString())) { throw new InvalidOperationException(Resources.ScaffoldLanguageNotSupported); } return(CodeDomProvider.CreateProvider(projectLanguage.ToString())); }
public Project AddProject(string projectName, ProjectTemplate projectTemplate, ProjectLanguage projectLanguage) { var projectPath = Path.Combine(DirectoryName, projectName); var projectTemplatePath = GetProjectTemplatePath(projectTemplate, projectLanguage); var dteProject = IntegrationHelper.RetryRpcCall(() => _dteSolution.AddFromTemplate(projectTemplatePath, projectPath, projectName, Exclusive: false)); if (dteProject == null) { dteProject = GetDteProject(projectName); } return new Project(dteProject, this, projectLanguage); }
public void LoadById() { Language language = LoadLanguage("ABAP"); Project project = LoadProject(); ProjectLanguageList projectLanguages = new ProjectLanguageList(); projectLanguages.Load(); ProjectLanguage projectLanguage = new ProjectLanguage(); projectLanguage.LoadById(projectLanguages.FirstOrDefault(p => p.LanguageId == language.Id && p.ProjectId == project.Id).Id); Assert.IsNotNull(projectLanguage); }
public void Insert() { Language language = LoadLanguage("ABAP"); Project project = LoadProject(); ProjectLanguage projectLanguage = new ProjectLanguage() { LanguageId = language.Id, ProjectId = project.Id }; int rowsInserted = projectLanguage.Insert(); Assert.IsTrue(rowsInserted == 1); }
internal static string GetViewFileExtension(ProjectLanguage language) { if (language == null) { throw new ArgumentNullException("language"); } if (language == ProjectLanguage.CSharp) { return("cshtml"); } else { throw new InvalidOperationException("Language Not Supported"); } }
internal static string GetViewFileExtension(ProjectLanguage language) { if (language == null) { throw new ArgumentNullException("language"); } if ((object)language == (object)ProjectLanguage.CSharp) { return("cshtml"); } if ((object)language != (object)ProjectLanguage.VisualBasic) { throw new InvalidOperationException("The project language is not supported."); } return("vbhtml"); }
internal Project(DteProject dteProject, Solution solution, ProjectLanguage language) { if (dteProject == null) { throw new ArgumentNullException(nameof(dteProject)); } if (solution == null) { throw new ArgumentNullException(nameof(solution)); } _dteProject = dteProject; _solution = solution; _language = language; }
private bool IsFileValid(string file, string expectedLanguage, string unExpectedLanguage) { if (ProjectLanguage == null) { throw new ExceptionFromResource("NoProgrammingLanguageSpecified"); } var expectedProjectLanguage = expectedLanguage; expectedLanguage = expectedLanguage == "C#" ? "cs" : expectedLanguage; unExpectedLanguage = unExpectedLanguage == "C#" ? "cs" : unExpectedLanguage; return((ProjectLanguage.Equals(expectedProjectLanguage, StringComparison.OrdinalIgnoreCase)) && (file.Split('/').Any(x => x.Equals(ProjectLanguage, StringComparison.OrdinalIgnoreCase)) || !file.Split('/').Any(x => x.Equals(unExpectedLanguage, StringComparison.OrdinalIgnoreCase)))); }
public void Delete() { Language language = LoadLanguage("MATLAB"); Project project = LoadProject(); ProjectLanguageList projectLanguages = new ProjectLanguageList(); projectLanguages.Load(); ProjectLanguage projectLanguage = new ProjectLanguage(); projectLanguage.LoadById(projectLanguages.FirstOrDefault(p => p.LanguageId == language.Id && p.ProjectId == project.Id).Id); int rowsAffected = projectLanguage.Delete(); Assert.IsTrue(rowsAffected == 1); }
private string LanguageAsStr(ProjectLanguage lang) { if (lang == ProjectLanguage.CSharp) { return("C#"); } else if (lang == ProjectLanguage.VB) { return("VB"); } else if (lang == ProjectLanguage.FSharp) { return("F#"); } else { throw new NotImplementedException("Unknown language"); } }
public static string GetErrorIfInvalidIdentifier(string text, ProjectLanguage projectLanguage) { if (string.IsNullOrEmpty(text)) { return("The name is invalid because it is empty."); } if (text.IndexOfAny(ValidationUtil._invalidCharacters) >= 0) { return(string.Format(CultureInfo.CurrentCulture, "The name is not allowed to contain any of these characters: {0}", string.Join <char>(" ", ValidationUtil.DisplayInvalidCharacters))); } if (text.Any <char>((char c) => char.IsWhiteSpace(c))) { return("The name is invalid because it has white spaces."); } if (!ValidationUtil.GenerateCodeDomProvider(projectLanguage).IsValidIdentifier(text)) { return("The name is invalid because it is a reserved name."); } return(null); }
// TODO: Adjust language name based on whether we are using a web template private string GetProjectTemplatePath(ProjectTemplate projectTemplate, ProjectLanguage projectLanguage) => IntegrationHelper.RetryRpcCall(() => _dteSolution.GetProjectTemplate(_projectTemplates[projectTemplate], ProjectLanguages[projectLanguage]));
public static string GetProjectTemplate(this DTE dte, ProjectKind kind, ProjectLanguage lang) { Debug.Assert(dte != null, "GetTemplateRootPath: dte is null"); return string.Format(dte.GetTemplatePath(ProjectTemplates[(int)lang][(int)kind]), "ProjectTemplatesCache"); }
/// <summary> /// Create a new project using specified info /// </summary> /// <param name="dte">dte instance</param> /// <param name="projectName">project name</param> /// <param name="kind">project kind</param> /// <param name="language">project language</param> /// <returns>new created project</returns> public static Project CreateProject( this DTE dte, string solutionPath, string projectName, ProjectKind kind, ProjectLanguage language) { Debug.Assert(dte != null, "CreateProject: Dte is null"); Debug.Assert(!string.IsNullOrEmpty(solutionPath), "!string.IsNullOrEmpty(solutionPath)"); Debug.Assert(!string.IsNullOrEmpty(projectName), "!string.IsNullOrEmpty(projectName)"); Debug.Assert(dte.Solution != null, "CreateProject: dte.Solution must be created by adding project"); var template = GetProjectTemplate(dte, kind, language); // Check if the project directory exists delete it does since AddFromTemplate will throw if the directory exists. var projectDir = Path.Combine(solutionPath, projectName); if (Directory.Exists(projectDir)) { Directory.Delete(projectDir, true); } dte.Solution.AddFromTemplate(template, Path.Combine(solutionPath, projectName), projectName, false); foreach (Project project in dte.Solution.Projects) { if (project.Name.Contains(projectName)) // Venus projects Name is the full path name - so need to use Contains() { return project; } } Debug.Fail("There is no new project created."); return null; }
public Project GetProject(string projectName, ProjectLanguage projectLanguage) { DteProject dteProject = GetDteProject(projectName); return new Project(dteProject, this, projectLanguage); }
internal static string GetViewFileExtension(ProjectLanguage language) { if (language == null) { throw new ArgumentNullException("language"); } if (language == ProjectLanguage.CSharp) { return "cshtml"; } else if (language == ProjectLanguage.VisualBasic) { return "vbhtml"; } else { throw new InvalidOperationException(Resources.ScaffoldLanguageNotSupported); } }