Merge pull request #87518 from paulloz/dotnet/fix-warnings
Clean a number of C# warnings
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace System.Diagnostics.CodeAnalysis
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue)]
|
||||
public sealed class NotNullAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Godot.SourceGenerators
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
[Conditional("DEBUG")]
|
||||
public static void ThrowIfNull([NotNull] object? value)
|
||||
{
|
||||
_ = value ?? throw new ArgumentNullException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
@@ -34,7 +33,7 @@ namespace Godot.SourceGenerators
|
||||
|
||||
// Method invocation or variable declaration that contained the type arguments
|
||||
var parentSyntax = context.Node.Parent;
|
||||
Debug.Assert(parentSyntax != null);
|
||||
Helper.ThrowIfNull(parentSyntax);
|
||||
|
||||
var sm = context.SemanticModel;
|
||||
|
||||
@@ -49,9 +48,10 @@ namespace Godot.SourceGenerators
|
||||
continue;
|
||||
|
||||
var typeSymbol = sm.GetSymbolInfo(typeSyntax).Symbol as ITypeSymbol;
|
||||
Debug.Assert(typeSymbol != null);
|
||||
Helper.ThrowIfNull(typeSymbol);
|
||||
|
||||
var parentSymbol = sm.GetSymbolInfo(parentSyntax).Symbol;
|
||||
Helper.ThrowIfNull(parentSymbol);
|
||||
|
||||
if (!ShouldCheckTypeArgument(context, parentSyntax, parentSymbol, typeSyntax, typeSymbol, i))
|
||||
{
|
||||
@@ -69,7 +69,7 @@ namespace Godot.SourceGenerators
|
||||
|
||||
var marshalType = MarshalUtils.ConvertManagedTypeToMarshalType(typeSymbol, typeCache);
|
||||
|
||||
if (marshalType == null)
|
||||
if (marshalType is null)
|
||||
{
|
||||
Common.ReportGenericTypeArgumentMustBeVariant(context, typeSyntax, typeSymbol);
|
||||
continue;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Godot.SourceGenerators
|
||||
.Append(" /// </summary>\n");
|
||||
|
||||
source.Append(
|
||||
$" public new class MethodName : {symbol.BaseType.FullQualifiedNameIncludeGlobal()}.MethodName {{\n");
|
||||
$" public new class MethodName : {symbol.BaseType!.FullQualifiedNameIncludeGlobal()}.MethodName {{\n");
|
||||
|
||||
// Generate cached StringNames for methods and properties, for fast lookup
|
||||
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ namespace Godot.SourceGenerators
|
||||
.Append(" /// </summary>\n");
|
||||
|
||||
source.Append(
|
||||
$" public new class PropertyName : {symbol.BaseType.FullQualifiedNameIncludeGlobal()}.PropertyName {{\n");
|
||||
$" public new class PropertyName : {symbol.BaseType!.FullQualifiedNameIncludeGlobal()}.PropertyName {{\n");
|
||||
|
||||
// Generate cached StringNames for methods and properties, for fast lookup
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Godot.SourceGenerators
|
||||
.Append(" /// </summary>\n");
|
||||
|
||||
source.Append(
|
||||
$" public new class SignalName : {symbol.BaseType.FullQualifiedNameIncludeGlobal()}.SignalName {{\n");
|
||||
$" public new class SignalName : {symbol.BaseType!.FullQualifiedNameIncludeGlobal()}.SignalName {{\n");
|
||||
|
||||
// Generate cached StringNames for methods and properties, for fast lookup
|
||||
|
||||
|
||||
Reference in New Issue
Block a user