Пример #1
0
        public static void AddExternalNotNullMethods(Compilation compilation, AdditionalText config)
        {
            lock (ExternalNotNullMethods)
            {
                var text = config.GetText();
                if (lastConfigLength == text.Length)
                {
                    return;
                }
                ExternalNotNullMethods.Clear();
                lastConfigLength = text.Length;
                // SourceText.Lines sometimes doesn't actually split the text into multiple lines
                foreach (var method in text.ToString().Split('\n').Select(i => i.Trim()))
                {
                    if (!method.Contains("."))
                    {
                        return;
                    }

                    foreach (var match in ParseMethodName(compilation, method))
                    {
                        ExternalNotNullMethods.Add(match);
                    }
                }
            }
        }
Пример #2
0
        public bool IsMethodCallThatIsNotNull(IMethodSymbol method)
        {
            using (new OperationTimer(i => Timings.Update(TimingOperation.SymbolLookup, i)))
            {
                var reduced = method.OriginalDefinition.ReducedFrom ?? method.OriginalDefinition;

                if (NotNullFrameworkMethods.Contains(reduced) || ExternalNotNullMethods.Contains(reduced))
                {
                    return(true);
                }
                return(false);
            }
        }
Пример #3
0
 public bool IsPropertyThatIsNotNull(ISymbol property)
 {
     if (DictionaryValues != null && DictionaryValues.Equals(property.OriginalDefinition))
     {
         return(true);
     }
     if (DictionaryValues != null && DictionaryKeys.Equals(property.OriginalDefinition))
     {
         return(true);
     }
     if (ExternalNotNullMethods.Contains(property))
     {
         return(true);
     }
     return(false);
 }