/// <summary> /// Get the clang tidy parameters from the Predefined Checks option page /// </summary> /// <returns>The predefined checks</returns> private string GetTidyPredefinedChecks() { var parameters = string.Empty; foreach (PropertyInfo prop in mTidyChecks.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(mTidyChecks, null); if (Boolean.TrueString != value.ToString()) { continue; } parameters = $"{parameters},{displayNameAttr.DisplayName}"; } return(parameters); }
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); }
private string GetPredefinedChecks(ClangTidyPredefinedChecksOptionsView predefinedChecksSettings) { StringBuilder predefinedChecks = new StringBuilder(); PropertyInfo[] properties = predefinedChecksSettings.GetType().GetProperties(); foreach (var item in properties) { var attribute = item.GetCustomAttribute(typeof(DisplayNameAttribute)) as DisplayNameAttribute; bool?value = item.GetValue(predefinedChecksSettings) as bool?; if (value != null && value == true && attribute != null) { predefinedChecks.Append(attribute.DisplayName + ","); } } return(predefinedChecks.ToString().TrimEnd(',')); }