mirror of
https://github.com/github/codeql.git
synced 2026-03-17 04:56:58 +01:00
C#: Fix nullability warnings after .net 5 upgrade
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// Gets the property symbol associated accessor `symbol`, or `null`
|
||||
/// if there is no associated symbol.
|
||||
/// </summary>
|
||||
public static IPropertySymbol GetPropertySymbol(IMethodSymbol symbol)
|
||||
public static IPropertySymbol? GetPropertySymbol(IMethodSymbol symbol)
|
||||
{
|
||||
// Usually, the property/indexer can be fetched from the associated symbol
|
||||
if (symbol.AssociatedSymbol is IPropertySymbol prop)
|
||||
@@ -29,7 +29,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
/// <summary>
|
||||
/// Gets the property symbol associated with this accessor.
|
||||
/// </summary>
|
||||
private IPropertySymbol PropertySymbol => GetPropertySymbol(Symbol);
|
||||
private IPropertySymbol? PropertySymbol => GetPropertySymbol(Symbol);
|
||||
|
||||
public new Accessor OriginalDefinition => Create(Context, Symbol.OriginalDefinition);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
|
||||
protected virtual T BodyDeclaringSymbol => Symbol;
|
||||
|
||||
public BlockSyntax Block
|
||||
public BlockSyntax? Block
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -112,7 +112,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public ExpressionSyntax ExpressionBody
|
||||
public ExpressionSyntax? ExpressionBody
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
private ConstructorDeclarationSyntax Syntax
|
||||
private ConstructorDeclarationSyntax? Syntax
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -122,7 +122,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.Write(";constructor");
|
||||
}
|
||||
|
||||
private ConstructorDeclarationSyntax GetSyntax() =>
|
||||
private ConstructorDeclarationSyntax? GetSyntax() =>
|
||||
Symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<ConstructorDeclarationSyntax>().FirstOrDefault();
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location? FullLocation => ReportingLocation;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
public static new Conversion Create(Context cx, IMethodSymbol symbol) =>
|
||||
ConversionFactory.Instance.CreateEntityFromSymbol(cx, symbol);
|
||||
|
||||
public override Microsoft.CodeAnalysis.Location ReportingLocation
|
||||
public override Microsoft.CodeAnalysis.Location? ReportingLocation
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
if (block != null)
|
||||
Statements.Block.Create(Context, block, this, 0);
|
||||
else
|
||||
Expression.Create(Context, expr, this, 0);
|
||||
Expression.Create(Context, expr!, this, 0);
|
||||
|
||||
NumberOfLines(trapFile, BodyDeclaringSymbol, this);
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Semmle.Extraction.CSharp
|
||||
}
|
||||
|
||||
var versionInfo = FileVersionInfo.GetVersionInfo(SpecifiedCompiler);
|
||||
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename, out var vendor))
|
||||
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename ?? string.Empty, out var vendor))
|
||||
{
|
||||
SkipExtractionBecause("the compiler name is not recognised");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user