public static ClangTidyOptionsView GetClangTidyOptionViewFromFile() { ClangTidyOptionsView clangTidyOptionsView = new ClangTidyOptionsView(); clangTidyOptionsView.LoadSettingsFromStorage(); return(clangTidyOptionsView); }
private string GetTidyParameters(ClangTidyOptionsView aTidyOptions, ClangTidyPredefinedChecksOptionsView aTidyChecks, ClangTidyCustomChecksOptionsView aTidyCustomChecks) { string parameters = string.Empty; if (0 == string.Compare(ComboBoxConstants.kTidyFile, ClangTidyUseChecksFromConvertor.ToString(aTidyOptions.UseChecksFrom))) { parameters = ScriptConstants.kTidyFile; mUseTidyFile = true; } else if (0 == string.Compare(ComboBoxConstants.kCustomChecks, ClangTidyUseChecksFromConvertor.ToString(aTidyOptions.UseChecksFrom))) { if (false == string.IsNullOrWhiteSpace(aTidyCustomChecks.TidyChecks)) { parameters = $",{aTidyCustomChecks.TidyChecks.Replace(';', ',')}"; } } else if (0 == string.Compare(ComboBoxConstants.kPredefinedChecks, ClangTidyUseChecksFromConvertor.ToString(aTidyOptions.UseChecksFrom))) { foreach (PropertyInfo prop in aTidyChecks.GetType().GetProperties()) { object[] propAttrs = prop.GetCustomAttributes(false); object clangCheckAttr = propAttrs.FirstOrDefault(attr => typeof(ClangCheckAttribute) == attr.GetType()); object displayNameAttrObj = propAttrs.FirstOrDefault(attr => typeof(DisplayNameAttribute) == attr.GetType()); if (null == clangCheckAttr || null == displayNameAttrObj) { continue; } DisplayNameAttribute displayNameAttr = (DisplayNameAttribute)displayNameAttrObj; var value = prop.GetValue(aTidyChecks, null); if (Boolean.TrueString != value.ToString()) { continue; } parameters = $"{parameters},{displayNameAttr.DisplayName}"; } } if (string.Empty != parameters) { parameters = string.Format("{0} ''{1}{2}''", (true == aTidyOptions.Fix ? ScriptConstants.kTidyFix : ScriptConstants.kTidy), (mUseTidyFile ? "" : "-*"), parameters); } if (null != aTidyOptions.HeaderFilter && false == string.IsNullOrWhiteSpace(aTidyOptions.HeaderFilter.HeaderFilters)) { parameters = string.Format("{0} {1} ''{2}''", parameters, ScriptConstants.kHeaderFilter, true == string.IsNullOrWhiteSpace(ClangTidyHeaderFiltersConvertor.ScriptEncode(aTidyOptions.HeaderFilter.HeaderFilters)) ? aTidyOptions.HeaderFilter.HeaderFilters : ClangTidyHeaderFiltersConvertor.ScriptEncode(aTidyOptions.HeaderFilter.HeaderFilters)); } return(parameters); }
public async Task ClangTidyOptionsView_NotNullAsync() { //Arrange await UnitTestUtility.LoadPackageAsync(); //Act ClangTidyOptionsView tidySettings = SettingsProvider.TidySettings; //Assert Assert.NotNull(tidySettings); }
public ClangTidyOptionsUserControl(ClangTidyOptionsView clangTidyOptions) { InitializeComponent(); wpfPropGrid.SelectedObject = clangTidyOptions; Loaded += delegate { UIElementsActivator.Activate(HwndSource.FromVisual(this) as HwndSource); }; }
/// <summary> /// Instance constructor /// </summary> public GenericScriptBuilder(ClangGeneralOptionsView aGeneralOptions, ClangTidyOptionsView aTidyOptions, ClangTidyPredefinedChecksOptionsView aTidyChecks, ClangTidyCustomChecksOptionsView aTidyCustomChecks, ClangFormatOptionsView aClangFormatView, string aVsEdition, string aVsVersion, bool aTidyFixFlag = false) { mGeneralOptions = aGeneralOptions; mTidyOptions = aTidyOptions; mTidyChecks = aTidyChecks; mTidyCustomChecks = aTidyCustomChecks; mClangFormatView = aClangFormatView; mVsEdition = aVsEdition; mVsVersion = aVsVersion; mTidyFixFlag = aTidyFixFlag; mUseClangTidyConfigFile = false; }
public async Task ChecksFrom_ChangeValue_CompareViewToFileAsync() { await UnitTestUtility.LoadPackageAsync(); SettingsTestUtility.ResetClangTidyOptionsView(); ClangTidyOptionsView tidySettings = SettingsProvider.TidySettings; tidySettings.UseChecksFrom = ClangTidyUseChecksFrom.TidyFile; SettingsTestUtility.SaveTidyOptions(tidySettings); ClangTidyOptionsView clangTidySettingsFromFile = SettingsTestUtility.GetClangTidyOptionViewFromFile(); Assert.Equal(tidySettings.UseChecksFrom, clangTidySettingsFromFile.UseChecksFrom); }
public async Task HeaderFilter_ChangeValue_CompareViewToFileAsync() { await UnitTestUtility.LoadPackageAsync(); SettingsTestUtility.ResetClangTidyOptionsView(); ClangTidyOptionsView tidySettings = SettingsProvider.TidySettings; tidySettings.HeaderFilter.HeaderFilters = "test"; SettingsTestUtility.SaveTidyOptions(tidySettings); ClangTidyOptionsView clangTidySettingsFromFile = SettingsTestUtility.GetClangTidyOptionViewFromFile(); Assert.Equal(tidySettings.HeaderFilter.HeaderFilters, clangTidySettingsFromFile.HeaderFilter.HeaderFilters); }
public async Task ClangTidyOnSave_ChangeValue_CompareViewToFileAsync() { await UnitTestUtility.LoadPackageAsync(); SettingsTestUtility.ResetClangTidyOptionsView(); ClangTidyOptionsView tidySettings = SettingsProvider.TidySettings; tidySettings.AutoTidyOnSave = true; SettingsTestUtility.SaveTidyOptions(tidySettings); ClangTidyOptionsView clangTidySettingsFromFile = SettingsTestUtility.GetClangTidyOptionViewFromFile(); Assert.Equal(tidySettings.AutoTidyOnSave, clangTidySettingsFromFile.AutoTidyOnSave); }
public void ConstructParameters(ClangGeneralOptionsView aGeneralOptions, ClangTidyOptionsView aTidyOptions, ClangTidyChecksOptionsView aTidyChecks, ClangTidyCustomChecksOptionsView aTidyCustomChecks, ClangFormatOptionsView aClangFormatView, DTE2 aDTEObj, string aVsEdition, string aVsVersion) { mParameters = GetGeneralParameters(aGeneralOptions); mParameters = null != aTidyOptions ? $"{mParameters} {GetTidyParameters(aTidyOptions, aTidyChecks, aTidyCustomChecks)}" : $"{mParameters} {ScriptConstants.kParallel}"; if (null != aClangFormatView && null != aTidyOptions && true == aTidyOptions.Fix && true == aTidyOptions.FormatAfterTidy) { mParameters = $"{mParameters} {ScriptConstants.kClangFormatStyle} {GetClangFormatParameters(aClangFormatView)}"; } mParameters = $"{mParameters} {ScriptConstants.kVsVersion} {aVsVersion} {ScriptConstants.kVsEdition} {aVsEdition}"; }
public async Task CustomExecutable_ChangeValue_CompareViewToFileAsync() { await UnitTestUtility.LoadPackageAsync(); SettingsTestUtility.ResetClangTidyOptionsView(); ClangTidyOptionsView tidySettings = SettingsProvider.TidySettings; tidySettings.ClangTidyPath.Enable = true; tidySettings.ClangTidyPath.Value = @"D:\Test.exe"; SettingsTestUtility.SaveTidyOptions(tidySettings); ClangTidyOptionsView clangTidySettingsFromFile = SettingsTestUtility.GetClangTidyOptionViewFromFile(); Assert.Equal(tidySettings.ClangTidyPath.Enable, clangTidySettingsFromFile.ClangTidyPath.Enable); Assert.Equal(tidySettings.ClangTidyPath.Value, clangTidySettingsFromFile.ClangTidyPath.Value); }
public static void SaveTidyOptions(ClangTidyOptionsView clangTidyOptionsView) { clangTidyOptionsView.SaveSettingsToStorage(); }