Skip to content

Commit 69e8621

Browse files
committed
C#: Fix compiler warning of possible null de-reference.
1 parent 5442cdb commit 69e8621

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Attribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private void ExtractArguments(TextWriter trapFile)
9191
// The current argument is not named
9292
// so the previous ones were also not named
9393
// so the child index matches the parameter index.
94-
isParamsParameter = Symbol?.AttributeConstructor?.Parameters[childIndex].IsParams == true;
94+
isParamsParameter = Symbol.AttributeConstructor?.Parameters[childIndex].IsParams == true;
9595
argSyntax = ctorArguments[childIndex];
9696
}
9797

csharp/extractor/Semmle.Extraction.CSharp/Entities/NonGeneratedSourceLocation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public override void Populate(TextWriter trapFile)
2222
Position.Span.Start.Line + 1, Position.Span.Start.Character + 1,
2323
Position.Span.End.Line + 1, Position.Span.End.Character);
2424

25-
var mapped = Symbol!.GetMappedLineSpan();
25+
var mapped = Symbol.GetMappedLineSpan();
2626
if (mapped.HasMappedPath && mapped.IsValid)
2727
{
2828
var mappedLoc = Create(Context, Location.Create(mapped.Path, default, mapped.Span));

csharp/extractor/Semmle.Extraction/Entities/Base/CachedEntity`1.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics.CodeAnalysis;
12
using System.IO;
23
using Microsoft.CodeAnalysis;
34

@@ -30,6 +31,7 @@ protected CachedEntity(Context context) : base(context)
3031
/// <typeparam name="TSymbol">The type of the symbol.</typeparam>
3132
public abstract class CachedEntity<TSymbol> : CachedEntity where TSymbol : notnull
3233
{
34+
[NotNull]
3335
public TSymbol Symbol { get; }
3436

3537
protected CachedEntity(Context context, TSymbol symbol) : base(context)
@@ -52,7 +54,7 @@ public string DebugContents
5254

5355
public override bool NeedsPopulation { get; }
5456

55-
public override int GetHashCode() => Symbol is null ? 0 : Symbol.GetHashCode();
57+
public override int GetHashCode() => Symbol.GetHashCode();
5658

5759
public override bool Equals(object? obj)
5860
{

0 commit comments

Comments
 (0)