diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs index 08e8f391a342..a70b84dde1df 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs @@ -91,7 +91,7 @@ private void ExtractArguments(TextWriter trapFile) // The current argument is not named // so the previous ones were also not named // so the child index matches the parameter index. - isParamsParameter = Symbol?.AttributeConstructor?.Parameters[childIndex].IsParams == true; + isParamsParameter = Symbol.AttributeConstructor?.Parameters[childIndex].IsParams == true; argSyntax = ctorArguments[childIndex]; } diff --git a/csharp/extractor/Semmle.Extraction.CSharp/Entities/NonGeneratedSourceLocation.cs b/csharp/extractor/Semmle.Extraction.CSharp/Entities/NonGeneratedSourceLocation.cs index f479f607e9cb..e3e3c0c6ae4a 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp/Entities/NonGeneratedSourceLocation.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp/Entities/NonGeneratedSourceLocation.cs @@ -22,7 +22,7 @@ public override void Populate(TextWriter trapFile) Position.Span.Start.Line + 1, Position.Span.Start.Character + 1, Position.Span.End.Line + 1, Position.Span.End.Character); - var mapped = Symbol!.GetMappedLineSpan(); + var mapped = Symbol.GetMappedLineSpan(); if (mapped.HasMappedPath && mapped.IsValid) { var mappedLoc = Create(Context, Location.Create(mapped.Path, default, mapped.Span)); diff --git a/csharp/extractor/Semmle.Extraction/Entities/Base/CachedEntity`1.cs b/csharp/extractor/Semmle.Extraction/Entities/Base/CachedEntity`1.cs index 4ef36362733c..82ded71a9cd5 100644 --- a/csharp/extractor/Semmle.Extraction/Entities/Base/CachedEntity`1.cs +++ b/csharp/extractor/Semmle.Extraction/Entities/Base/CachedEntity`1.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.IO; using Microsoft.CodeAnalysis; @@ -30,6 +31,7 @@ protected CachedEntity(Context context) : base(context) /// The type of the symbol. public abstract class CachedEntity : CachedEntity where TSymbol : notnull { + [NotNull] public TSymbol Symbol { get; } protected CachedEntity(Context context, TSymbol symbol) : base(context)