Exposes the found nullability attributes as (source or external) symbols.
        public NullabilityAttributeSymbols GetSymbols(Compilation compilation,
                                                      CancellationToken cancellationToken = default(CancellationToken))
        {
            Guard.NotNull(compilation, nameof(compilation));

            NullabilityAttributeSymbols symbolsSnapshot = symbols.Value;

            NullabilityAttributeMetadataNames previousNames =
                symbolsSnapshot?.GetMetadataNames() ?? names.Value ?? LastSeenNames.Value;

            symbolsSnapshot = previousNames?.GetSymbolsOrNull(compilation);

            if (symbolsSnapshot == null)
            {
                var provider = new SimpleNullabilityAttributeProvider();
                symbolsSnapshot = provider.GetSymbols(compilation, cancellationToken);
            }

            if (symbolsSnapshot != null)
            {
                names.Value         = symbolsSnapshot.GetMetadataNames();
                LastSeenNames.Value = names.Value;
            }

            symbols.Value = symbolsSnapshot;
            return(symbolsSnapshot);
        }
Ejemplo n.º 2
0
        public NullabilityAttributeSymbols Scan([NotNull] Compilation compilation, CancellationToken cancellationToken)
        {
            Guard.NotNull(compilation, nameof(compilation));

            NullabilityAttributeSymbols result = ScanInSources(compilation, cancellationToken);

            return(result ?? ScanInReferences(compilation, cancellationToken));
        }