/// <summary> /// Gets the RuleSet associated with this ruleset include /// </summary> /// <param name="parent">The parent of this ruleset include</param> public RuleSet LoadRuleSet(RuleSet parent) { // Try to load the rule set RuleSet ruleSet = null; string path = _includePath; try { path = GetIncludePath(parent); ruleSet = RuleSetProcessor.LoadFromFile(path); } catch (FileNotFoundException) { // The compiler uses the same rule set files as FxCop, but doesn't have all of // the same logic for resolving included files. For the moment, just ignore any // includes we can't resolve. } catch (Exception e) { throw new InvalidRuleSetException(string.Format(CodeAnalysisResources.InvalidRuleSetInclude, path, e.Message)); } return(ruleSet); }
/// <summary> /// Get the paths to all files contributing rules to the ruleset from the specified file. /// See also: <seealso cref="LoadEffectiveRuleSetFromFile(string)" />. /// </summary> /// <returns> /// The full paths to included files, or an empty array if there were errors. /// </returns> public static ImmutableArray <string> GetEffectiveIncludesFromFile(string filePath) { var ruleSet = RuleSetProcessor.LoadFromFile(filePath); if (ruleSet != null) { return(ruleSet.GetEffectiveIncludes()); } return(ImmutableArray <string> .Empty); }
/// <summary> /// Load the ruleset from the specified file. This ruleset will contain /// all the rules resolved from the includes specified in the ruleset file /// as well. See also: <seealso cref="GetEffectiveIncludesFromFile(string)" />. /// </summary> /// <returns> /// A ruleset that contains resolved rules or null if there were errors. /// </returns> public static RuleSet LoadEffectiveRuleSetFromFile(string filePath) { var ruleSet = RuleSetProcessor.LoadFromFile(filePath); if (ruleSet != null) { return(ruleSet.GetEffectiveRuleSet(new HashSet <string>())); } return(null); }