Ejemplo n.º 1
0
        private ImmutableDictionary <string, ImmutableArray <DiagnosticDescriptor> > ConvertReferenceIdentityToName(
            ImmutableDictionary <object, ImmutableArray <DiagnosticDescriptor> > descriptorsPerReference, Project projectOpt = null)
        {
            var map = _hostAnalyzerManager.CreateAnalyzerReferencesMap(projectOpt);

            var builder = ImmutableDictionary.CreateBuilder <string, ImmutableArray <DiagnosticDescriptor> >();

            foreach (var kv in descriptorsPerReference)
            {
                var id          = kv.Key;
                var descriptors = kv.Value;

                AnalyzerReference reference;
                if (!map.TryGetValue(id, out reference) || reference == null)
                {
                    continue;
                }

                var displayName = GetDisplayName(reference);

                // if there are duplicates, merge descriptors
                ImmutableArray <DiagnosticDescriptor> existing;
                if (builder.TryGetValue(displayName, out existing))
                {
                    builder[displayName] = existing.AddRange(descriptors);
                    continue;
                }

                builder.Add(displayName, descriptors);
            }

            return(builder.ToImmutable());
        }
Ejemplo n.º 2
0
 private TestDiagnosticAnalyzerService(
     HostAnalyzerManager hostAnalyzerManager,
     AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource,
     Action <Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException,
     IDiagnosticUpdateSourceRegistrationService registrationService = null)
     : base(hostAnalyzerManager, hostDiagnosticUpdateSource, registrationService ?? new MockDiagnosticUpdateSourceRegistrationService())
 {
     _hostAnalyzerReferenceMap = hostAnalyzerManager.CreateAnalyzerReferencesMap(projectOpt: null);
     _onAnalyzerException      = onAnalyzerException;
 }
 private TestDiagnosticAnalyzerService(
     HostAnalyzerManager hostAnalyzerManager,
     AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource,
     Action<Exception, DiagnosticAnalyzer, Diagnostic> onAnalyzerException,
     IDiagnosticUpdateSourceRegistrationService registrationService = null)
     : base(hostAnalyzerManager, hostDiagnosticUpdateSource, registrationService ?? new MockDiagnosticUpdateSourceRegistrationService())
 {
     _hostAnalyzerReferenceMap = hostAnalyzerManager.CreateAnalyzerReferencesMap(projectOpt: null);
     _onAnalyzerException = onAnalyzerException;
 }