internal static XmlCodeAnalysisConfig LoadAndCatchIfThrows(string uri, XmlConfigLoadOptions options = XmlConfigLoadOptions.None, Action <Exception> exceptionHandler = null)
 {
     try
     {
         return(Load(uri, options));
     }
     catch (Exception ex) when(ex is IOException ||
                               ex is UnauthorizedAccessException ||
                               ex is XmlException)
     {
         exceptionHandler?.Invoke(ex);
         return(null);
     }
 }
        internal static XmlCodeAnalysisConfig Load(string path, XmlConfigLoadOptions options = XmlConfigLoadOptions.None)
        {
            if (!TryGetNormalizedFullPath(path, out path))
            {
                return(null);
            }

            Builder builder = null;

            Queue <string> queue = null;

            Load(path, ref builder, ref queue);

            ImmutableArray <string> includes = queue?.ToImmutableArray() ?? ImmutableArray <string> .Empty;

            if (queue != null &&
                (options & XmlConfigLoadOptions.SkipIncludes) == 0)
            {
                var loadedIncludes = new HashSet <string>(FileSystemHelpers.Comparer)
                {
                    path
                };

                do
                {
                    string include = queue.Dequeue();

                    if (!loadedIncludes.Contains(include) &&
                        Path.GetFileName(include) == XmlCodeAnalysisConfig.FileName &&
                        File.Exists(include))
                    {
                        try
                        {
                            Load(include, ref builder, ref queue);
                        }
                        catch (Exception ex) when(ex is IOException ||
                                                  ex is UnauthorizedAccessException ||
                                                  ex is XmlException)
                        {
                            Debug.Fail(ex.ToString());
                        }
                    }

                    loadedIncludes.Add(include);
                }while (queue.Count > 0);
            }

            if (builder == null)
            {
                return(null);
            }

            return(new XmlCodeAnalysisConfig(
                       includes: includes,
                       analyzers: builder.Analyzers?.ToImmutable() ?? ImmutableDictionary <string, bool> .Empty,
                       codeFixes: builder.CodeFixes?.ToImmutable() ?? ImmutableDictionary <string, bool> .Empty,
                       refactorings: builder.Refactorings?.ToImmutable() ?? ImmutableDictionary <string, bool> .Empty,
                       ruleSets: builder.RuleSets?.ToImmutable() ?? ImmutableArray <string> .Empty,
                       prefixFieldIdentifierWithUnderscore: builder.PrefixFieldIdentifierWithUnderscore,
                       maxLineLength: builder.MaxLineLength));
        }