Skip to content

Commit cfd8a87

Browse files
committed
C#: Fix nullability warnings after .net 5 upgrade
1 parent 828e1f8 commit cfd8a87

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ protected Accessor(Context cx, IMethodSymbol init)
1313
/// Gets the property symbol associated accessor `symbol`, or `null`
1414
/// if there is no associated symbol.
1515
/// </summary>
16-
public static IPropertySymbol GetPropertySymbol(IMethodSymbol symbol)
16+
public static IPropertySymbol? GetPropertySymbol(IMethodSymbol symbol)
1717
{
1818
// Usually, the property/indexer can be fetched from the associated symbol
1919
if (symbol.AssociatedSymbol is IPropertySymbol prop)
@@ -29,7 +29,7 @@ public static IPropertySymbol GetPropertySymbol(IMethodSymbol symbol)
2929
/// <summary>
3030
/// Gets the property symbol associated with this accessor.
3131
/// </summary>
32-
private IPropertySymbol PropertySymbol => GetPropertySymbol(Symbol);
32+
private IPropertySymbol? PropertySymbol => GetPropertySymbol(Symbol);
3333

3434
public new Accessor OriginalDefinition => Create(Context, Symbol.OriginalDefinition);
3535

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected void BindComments()
101101

102102
protected virtual T BodyDeclaringSymbol => Symbol;
103103

104-
public BlockSyntax Block
104+
public BlockSyntax? Block
105105
{
106106
get
107107
{
@@ -112,7 +112,7 @@ public BlockSyntax Block
112112
}
113113
}
114114

115-
public ExpressionSyntax ExpressionBody
115+
public ExpressionSyntax? ExpressionBody
116116
{
117117
get
118118
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected override void ExtractInitializers(TextWriter trapFile)
8686
}
8787
}
8888

89-
private ConstructorDeclarationSyntax Syntax
89+
private ConstructorDeclarationSyntax? Syntax
9090
{
9191
get
9292
{
@@ -122,7 +122,7 @@ public override void WriteId(TextWriter trapFile)
122122
trapFile.Write(";constructor");
123123
}
124124

125-
private ConstructorDeclarationSyntax GetSyntax() =>
125+
private ConstructorDeclarationSyntax? GetSyntax() =>
126126
Symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<ConstructorDeclarationSyntax>().FirstOrDefault();
127127

128128
public override Microsoft.CodeAnalysis.Location? FullLocation => ReportingLocation;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private Conversion(Context cx, IMethodSymbol init)
1313
public static new Conversion Create(Context cx, IMethodSymbol symbol) =>
1414
ConversionFactory.Instance.CreateEntityFromSymbol(cx, symbol);
1515

16-
public override Microsoft.CodeAnalysis.Location ReportingLocation
16+
public override Microsoft.CodeAnalysis.Location? ReportingLocation
1717
{
1818
get
1919
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private void PopulateMethodBody(TextWriter trapFile)
8383
if (block != null)
8484
Statements.Block.Create(Context, block, this, 0);
8585
else
86-
Expression.Create(Context, expr, this, 0);
86+
Expression.Create(Context, expr!, this, 0);
8787

8888
NumberOfLines(trapFile, BodyDeclaringSymbol, this);
8989
});

csharp/extractor/Semmle.Extraction.CSharp/Extractor/CompilerVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public CompilerVersion(Options options)
7575
}
7676

7777
var versionInfo = FileVersionInfo.GetVersionInfo(SpecifiedCompiler);
78-
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename, out var vendor))
78+
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename ?? string.Empty, out var vendor))
7979
{
8080
SkipExtractionBecause("the compiler name is not recognised");
8181
return;

0 commit comments

Comments
 (0)