Remove some null suppressions, add [NotNullWhen]

このコミットが含まれているのは:
Sergio Pedri committed 2023-06-14 23:19:13 +02:00
1 親 94002a662b
コミット aad8dd8d95
10ファイル変更
+17 -17

検索条件に一致するファイルはありません

+4 -4
ファイルの表示
@@ -85,12 +85,12 @@ partial class D2DPixelShaderSourceGenerator
{
if (methodSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out AttributeData? attributeData))
{
return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!;
return (D2D1ShaderProfile)attributeData.ConstructorArguments[0].Value!;
}
if (methodSymbol.ContainingAssembly.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out attributeData))
{
return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!;
return (D2D1ShaderProfile)attributeData.ConstructorArguments[0].Value!;
}
diagnostics.Add(
@@ -112,12 +112,12 @@ partial class D2DPixelShaderSourceGenerator
{
if (methodSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData))
{
return (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value!;
return (D2D1CompileOptions)attributeData.ConstructorArguments[0].Value!;
}
if (methodSymbol.ContainingAssembly.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out attributeData))
{
return (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value!;
return (D2D1CompileOptions)attributeData.ConstructorArguments[0].Value!;
}
diagnostics.Add(
@@ -31,7 +31,7 @@ public sealed class InvalidAssemblyLevelCompileOptionsAnalyzer : DiagnosticAnaly
// - The input D2D1CompileOptions value, which can be retrieved from the constructor arguments of the AttributeData object.
if (assemblySymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData))
{
D2D1CompileOptions options = (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value!;
D2D1CompileOptions options = (D2D1CompileOptions)attributeData.ConstructorArguments[0].Value!;
if ((options & D2D1CompileOptions.PackMatrixColumnMajor) != 0)
{
@@ -155,7 +155,7 @@ partial class ID2D1ShaderGenerator
// by the logic handling the info gathering for LoadResourceTextureDescriptions.
if (fieldSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DResourceTextureIndexAttribute", out AttributeData? attributeData))
{
_ = attributeData!.TryGetConstructorArgument(0, out index);
_ = attributeData.TryGetConstructorArgument(0, out index);
}
resourceTextures.Add((mapping ?? fieldSymbol.Name, typeName, index));
@@ -32,7 +32,7 @@ partial class ID2D1ShaderGenerator
}
// Extract the buffer precision and channel depth, if available
if (attributeData!.ConstructorArguments.Length == 1)
if (attributeData.ConstructorArguments.Length == 1)
{
if (attributeData.AttributeConstructor is IMethodSymbol { Parameters.Length: 1 } constructorSymbol &&
constructorSymbol.Parameters[0].Type.HasFullyQualifiedMetadataName("ComputeSharp.D2D1.D2D1BufferPrecision"))
@@ -20,7 +20,7 @@ partial class ID2D1ShaderGenerator
{
if (structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DPixelOptionsAttribute", out AttributeData? attributeData))
{
pixelOptions = (D2D1PixelOptions)attributeData!.ConstructorArguments[0].Value!;
pixelOptions = (D2D1PixelOptions)attributeData.ConstructorArguments[0].Value!;
}
else
{
@@ -35,12 +35,12 @@ partial class ID2D1ShaderGenerator
{
if (structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out AttributeData? attributeData))
{
return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!;
return (D2D1ShaderProfile)attributeData.ConstructorArguments[0].Value!;
}
if (structDeclarationSymbol.ContainingAssembly.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DShaderProfileAttribute", out attributeData))
{
return (D2D1ShaderProfile)attributeData!.ConstructorArguments[0].Value!;
return (D2D1ShaderProfile)attributeData.ConstructorArguments[0].Value!;
}
return null;
@@ -56,7 +56,7 @@ partial class ID2D1ShaderGenerator
{
if (structDeclarationSymbol.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out AttributeData? attributeData))
{
D2D1CompileOptions options = (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value!;
D2D1CompileOptions options = (D2D1CompileOptions)attributeData.ConstructorArguments[0].Value!;
if ((options & D2D1CompileOptions.PackMatrixColumnMajor) != 0)
{
@@ -73,7 +73,7 @@ partial class ID2D1ShaderGenerator
if (structDeclarationSymbol.ContainingAssembly.TryGetAttributeWithFullyQualifiedMetadataName("ComputeSharp.D2D1.D2DCompileOptionsAttribute", out attributeData))
{
// No need to validate against PackMatrixColumnMajor as that's checked separately
return (D2D1CompileOptions)attributeData!.ConstructorArguments[0].Value! | D2D1CompileOptions.PackMatrixRowMajor;
return (D2D1CompileOptions)attributeData.ConstructorArguments[0].Value! | D2D1CompileOptions.PackMatrixRowMajor;
}
return null;
@@ -56,7 +56,7 @@ partial class ID2D1ShaderGenerator
{
// If the constructor argument isn't available, it means the code is invalid. Just do nothing then, as the
// user will have to fix that to get the code to compile anyway. This way the generator won't crash too.
if (attributeData!.TryGetConstructorArgument(0, out int resourceIndex))
if (attributeData.TryGetConstructorArgument(0, out int resourceIndex))
{
index = resourceIndex;
}