C#: Use nameof in nullability attributes

This commit is contained in:
Tamas Vajk
2024-02-20 10:05:34 +01:00
parent ce07d6ad9f
commit b3f5beb076
4 changed files with 4 additions and 4 deletions

View File

@@ -140,7 +140,7 @@ namespace Semmle.Autobuild.Shared
/// <summary>
/// Returns the file name and extension of the specified path string.
/// </summary>
[return: NotNullIfNotNull("path")]
[return: NotNullIfNotNull(nameof(path))]
string? GetFileName(string? path);
/// <summary>

View File

@@ -126,7 +126,7 @@ namespace Semmle.Extraction.CSharp.Entities
}
}
[return: NotNullIfNotNull("constructor")]
[return: NotNullIfNotNull(nameof(constructor))]
public static new Constructor? Create(Context cx, IMethodSymbol? constructor)
{
if (constructor is null)

View File

@@ -232,7 +232,7 @@ namespace Semmle.Extraction.CSharp.Entities
/// <param name="cx"></param>
/// <param name="methodDecl"></param>
/// <returns></returns>
[return: NotNullIfNotNull("methodDecl")]
[return: NotNullIfNotNull(nameof(methodDecl))]
public static Method? Create(Context cx, IMethodSymbol? methodDecl)
{
if (methodDecl is null)

View File

@@ -591,7 +591,7 @@ namespace Semmle.Extraction.CSharp
public static INamedTypeSymbol? GetNonObjectBaseType(this ITypeSymbol symbol, Context cx) =>
symbol is ITypeParameterSymbol || SymbolEqualityComparer.Default.Equals(symbol.BaseType, cx.Compilation.ObjectType) ? null : symbol.BaseType;
[return: NotNullIfNotNull("symbol")]
[return: NotNullIfNotNull(nameof(symbol))]
public static IEntity? CreateEntity(this Context cx, ISymbol symbol)
{
if (symbol is null)