Add necessary parentheses and use target-typed new() expressions

このコミットが含まれているのは:
Sergio Pedri committed 2022-10-15 09:10:18 -07:00
1 親 b2afb88f30
コミット 553c7a4014
11ファイル変更
+43 -44

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

+1 -1
ファイルの表示
@@ -41,5 +41,5 @@ internal readonly struct Complex64
/// <param name="scalar">The <see cref="float"/> scalar to use to multiply the <see cref="Complex64"/> value.</param>
/// <returns>The <see cref="Complex64"/> result.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Complex64 operator *(Complex64 value, float scalar) => new Complex64(value.Real * scalar, value.Imaginary * scalar);
public static Complex64 operator *(Complex64 value, float scalar) => new(value.Real * scalar, value.Imaginary * scalar);
}
+1 -1
ファイルの表示
@@ -77,7 +77,7 @@ public sealed partial class HlslBokehBlurProcessor : IImageProcessor
ThrowHelper.ThrowInvalidOperationException("This processor only supports the RGBA32 pixel format.");
}
Implementation processor = new Implementation(this, configuration, Unsafe.As<Image<ImageSharpRgba32>>(source), sourceRectangle);
Implementation processor = new(this, configuration, Unsafe.As<Image<ImageSharpRgba32>>(source), sourceRectangle);
return Unsafe.As<IImageProcessor<TPixel>>(processor);
}
+1 -1
ファイルの表示
@@ -82,7 +82,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
ThrowHelper.ThrowInvalidOperationException("This processor only supports the RGBA32 pixel format.");
}
Implementation processor = new Implementation(this, configuration, Unsafe.As<Image<ImageSharpRgba32>>(source), sourceRectangle);
Implementation processor = new(this, configuration, Unsafe.As<Image<ImageSharpRgba32>>(source), sourceRectangle);
return Unsafe.As<IImageProcessor<TPixel>>(processor);
}
@@ -64,7 +64,7 @@ partial class ID2D1ShaderGenerator
out ImmutableArray<(string Name, string HlslType, int Index)> resourceTextureFields);
// Explore the syntax tree and extract the processed info
SemanticModelProvider semanticModelProvider = new SemanticModelProvider(compilation);
SemanticModelProvider semanticModelProvider = new(compilation);
(string entryPoint, ImmutableArray<(string Signature, string Definition)> processedMethods) = GetProcessedMethods(diagnostics, structDeclaration, structDeclarationSymbol, semanticModelProvider, discoveredTypes, staticMethods, instanceMethods, constantDefinitions, out bool methodsNeedD2D1RequiresScenePosition);
ImmutableArray<(string Name, string TypeDeclaration, string? Assignment)> staticFields = GetStaticFields(diagnostics, semanticModelProvider, structDeclaration, structDeclarationSymbol, discoveredTypes, constantDefinitions, out bool fieldsNeedD2D1RequiresScenePosition);
@@ -375,8 +375,8 @@ unsafe partial struct D2D1ResourceTextureManagerImpl
uint dataCount)
{
// Either both extents are available, or none is, and the other values must not be null
if (minimumExtents is null && maximimumExtents is not null ||
minimumExtents is not null && maximimumExtents is null ||
if ((minimumExtents is null && maximimumExtents is not null) ||
(minimumExtents is not null && maximimumExtents is null) ||
(dimensions > 1 && strides is null) ||
data is null)
{
@@ -1,40 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Diagnostics.CodeAnalysis
namespace System.Diagnostics.CodeAnalysis;
/// <summary>
/// Indicates that the specified method requires dynamic access to code that is not referenced
/// statically, for example through <see cref="System.Reflection"/>.
/// </summary>
/// <remarks>
/// This allows tools to understand which methods are unsafe to call when removing unreferenced
/// code from an application.
/// </remarks>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)]
internal sealed class RequiresUnreferencedCodeAttribute : Attribute
{
/// <summary>
/// Indicates that the specified method requires dynamic access to code that is not referenced
/// statically, for example through <see cref="System.Reflection"/>.
/// Initializes a new instance of the <see cref="RequiresUnreferencedCodeAttribute"/> class
/// with the specified message.
/// </summary>
/// <remarks>
/// This allows tools to understand which methods are unsafe to call when removing unreferenced
/// code from an application.
/// </remarks>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class, Inherited = false)]
internal sealed class RequiresUnreferencedCodeAttribute : Attribute
/// <param name="message">
/// A message that contains information about the usage of unreferenced code.
/// </param>
public RequiresUnreferencedCodeAttribute(string message)
{
/// <summary>
/// Initializes a new instance of the <see cref="RequiresUnreferencedCodeAttribute"/> class
/// with the specified message.
/// </summary>
/// <param name="message">
/// A message that contains information about the usage of unreferenced code.
/// </param>
public RequiresUnreferencedCodeAttribute(string message)
{
Message = message;
}
/// <summary>
/// Gets a message that contains information about the usage of unreferenced code.
/// </summary>
public string Message { get; }
/// <summary>
/// Gets or sets an optional URL that contains more information about the method,
/// why it requires unreferenced code, and what options a consumer has to deal with it.
/// </summary>
public string? Url { get; set; }
Message = message;
}
/// <summary>
/// Gets a message that contains information about the usage of unreferenced code.
/// </summary>
public string Message { get; }
/// <summary>
/// Gets or sets an optional URL that contains more information about the method,
/// why it requires unreferenced code, and what options a consumer has to deal with it.
/// </summary>
public string? Url { get; set; }
}
+1 -1
ファイルの表示
@@ -215,6 +215,6 @@ internal static class ISymbolExtensions
return
accessibility == Accessibility.Public ||
accessibility == Accessibility.Internal && symbol.ContainingAssembly.GivesAccessTo(assembly);
(accessibility == Accessibility.Internal && symbol.ContainingAssembly.GivesAccessTo(assembly));
}
}
+1 -1
ファイルの表示
@@ -58,7 +58,7 @@ partial class IShaderGenerator
}
// Explore the syntax tree and extract the processed info
SemanticModelProvider semanticModelProvider = new SemanticModelProvider(compilation);
SemanticModelProvider semanticModelProvider = new(compilation);
INamedTypeSymbol? pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IPixelShader<byte>) });
bool isComputeShader = pixelShaderSymbol is null;
string? implicitTextureType = isComputeShader ? null : HlslKnownTypes.GetMappedNameForPixelShaderType(pixelShaderSymbol!);
+1 -1
ファイルの表示
@@ -87,7 +87,7 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator
Dictionary<IMethodSymbol, MethodDeclarationSyntax> instanceMethods = new(SymbolEqualityComparer.Default); // Unused in this generator
// Explore the syntax tree and extract the processed info
SemanticModelProvider semanticModel = new SemanticModelProvider(compilation);
SemanticModelProvider semanticModel = new(compilation);
(string entryPoint, ImmutableArray<(string Signature, string Definition)> dependentMethods) = GetProcessedMethods(builder, methodDeclaration, semanticModel, discoveredTypes, constantDefinitions);
ImmutableArray<(string Name, string Definition)> definedTypes = IShaderGenerator.BuildHlslSource.GetDeclaredTypes(builder, methodSymbol, discoveredTypes, instanceMethods);
ImmutableArray<(string Name, string Value)> definedConstants = IShaderGenerator.BuildHlslSource.GetDefinedConstants(constantDefinitions);
+2 -2
ファイルの表示
@@ -55,7 +55,7 @@ internal static class TolerantImageComparer
float totalDifference = 0F;
List<PixelDifference> differences = new List<PixelDifference>(20);
List<PixelDifference> differences = new(20);
Span<ImageSharpRgba32> aBuffer = new ImageSharpRgba32[actual.Width];
Span<ImageSharpRgba32> bBuffer = new ImageSharpRgba32[actual.Width];
@@ -84,7 +84,7 @@ internal static class TolerantImageComparer
{
if (differences.Count < 20)
{
PixelDifference diff = new PixelDifference(new Point(x, y), aBuffer[x], bBuffer[x]);
PixelDifference diff = new(new Point(x, y), aBuffer[x], bBuffer[x]);
differences.Add(diff);
}
+2 -2
ファイルの表示
@@ -169,7 +169,7 @@ public class ShadersTests
texture.GraphicsDevice.For(texture.Width, texture.Height, (T)Activator.CreateInstance(typeof(T), texture, 0f)!);
}
Action<ReadWriteTexture2D<Rgba32, float4>> action = new Action<ReadWriteTexture2D<Rgba32, float4>>(RunComputeShader<SwapChain.Shaders.Compute.ColorfulInfinity>);
Action<ReadWriteTexture2D<Rgba32, float4>> action = new(RunComputeShader<SwapChain.Shaders.Compute.ColorfulInfinity>);
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
}
@@ -181,7 +181,7 @@ public class ShadersTests
texture.GraphicsDevice.ForEach(texture, (T)Activator.CreateInstance(typeof(T), 0f)!);
}
Action<ReadWriteTexture2D<Rgba32, float4>> action = new Action<ReadWriteTexture2D<Rgba32, float4>>(RunPixelShader<ColorfulInfinity>);
Action<ReadWriteTexture2D<Rgba32, float4>> action = new(RunPixelShader<ColorfulInfinity>);
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
}