Merge pull request #635 from Sergio0694/dev/analysis-tweaks
Apply some code tweaks to make analysis happy
このコミットが含まれているのは:
9ファイル変更
+14
-14
検索条件に一致するファイルはありません
@@ -9,10 +9,10 @@
|
||||
Enable the latest warning wave, which shows additional warnings for invalid language features that are disabled by default.
|
||||
For additional info, see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/warning-waves.
|
||||
-->
|
||||
<AnalysisLevel>7</AnalysisLevel>
|
||||
<AnalysisLevel>latest</AnalysisLevel>
|
||||
|
||||
<!-- Import the global configs from the CodeStyle package (enables all IDExxxx warnings)-->
|
||||
<AnalysisLevelStyle>7-all</AnalysisLevelStyle>
|
||||
<AnalysisLevelStyle>latest-all</AnalysisLevelStyle>
|
||||
|
||||
<!-- Enforce all code style rules during build (this replaces referencing Microsoft.CodeAnalysis.CSharp.CodeStyle) -->
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Globalization;
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
@@ -48,7 +49,7 @@ partial class D2DPixelShaderDescriptorGenerator
|
||||
if (HlslKnownTypes.IsResourceTextureType(metadataName))
|
||||
{
|
||||
// The type name will be ComputeSharp.D2D1.D2D1ResourceTexture1D`1 or the 2D/3D versions
|
||||
int rank = int.Parse(metadataName.Substring(metadataName.Length - 4, 1));
|
||||
int rank = int.Parse(metadataName.Substring(metadataName.Length - 4, 1), CultureInfo.InvariantCulture);
|
||||
int? index = null;
|
||||
|
||||
// Get the index from the [D2DResourceTextureIndex] attribute over the field
|
||||
|
||||
@@ -76,8 +76,6 @@ internal static partial class HlslKnownMethods
|
||||
["System.MathF.Exp"] = "exp",
|
||||
["System.MathF.Log"] = "log",
|
||||
["System.MathF.Log10"] = "log10",
|
||||
["System.MathF.Max"] = "max",
|
||||
["System.MathF.Min"] = "min",
|
||||
["System.MathF.Round"] = "round",
|
||||
["System.MathF.Sqrt"] = "sqrt",
|
||||
["System.MathF.Sign"] = "sign",
|
||||
|
||||
@@ -27,7 +27,7 @@ internal static partial class HlslKnownOperators
|
||||
foreach ((Type Type, MethodInfo Operator, string IntrinsicName, bool RequiresParametersMatching) item in
|
||||
from type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes)
|
||||
from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public)
|
||||
where method.IsSpecialName && method.Name.StartsWith("op_")
|
||||
where method.IsSpecialName && method.Name.StartsWith("op_", StringComparison.InvariantCulture)
|
||||
let attribute = method.GetCustomAttribute<HlslIntrinsicNameAttribute>()
|
||||
where attribute is not null
|
||||
select (Type: type, Operator: method, IntrinsicName: attribute.Name, attribute.RequiresParametersMatching))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -140,8 +141,8 @@ internal static partial class HlslKnownTypes
|
||||
if (match.Success)
|
||||
{
|
||||
elementName = match.Groups[1].Value;
|
||||
rows = int.Parse(match.Groups[2].Value);
|
||||
columns = int.Parse(match.Groups[3].Value);
|
||||
rows = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture);
|
||||
columns = int.Parse(match.Groups[3].Value, CultureInfo.InvariantCulture);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -247,7 +248,7 @@ internal static partial class HlslKnownTypes
|
||||
type.TypeKind is TypeKind.Enum ||
|
||||
type.IsGenericType ||
|
||||
type.IsRefLikeType ||
|
||||
type.GetFullyQualifiedName().StartsWith("System."))
|
||||
type.GetFullyQualifiedName().StartsWith("System.", StringComparison.InvariantCulture))
|
||||
{
|
||||
_ = invalidTypes.Add(type);
|
||||
|
||||
|
||||
@@ -491,7 +491,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
|
||||
ArgumentSyntax coordinateSyntax = mapping switch
|
||||
{
|
||||
not null => Argument(InvocationExpression(IdentifierName(mapping!), ArgumentList(updatedNode.ArgumentList.Arguments))),
|
||||
null => updatedNode.ArgumentList.Arguments[0]
|
||||
_ => updatedNode.ArgumentList.Arguments[0]
|
||||
};
|
||||
|
||||
// Rewrite texture resource sampled accesses, if needed
|
||||
|
||||
@@ -50,13 +50,13 @@ internal static class IndentedTextWriterExtensions
|
||||
public static void WriteSortedUsingDirectives(this IndentedTextWriter writer, IEnumerable<string> usingDirectives)
|
||||
{
|
||||
// Add the System directives first, in the correct order
|
||||
foreach (string usingDirective in usingDirectives.Where(static name => name.StartsWith("global::System")).OrderBy(static name => name))
|
||||
foreach (string usingDirective in usingDirectives.Where(static name => name.StartsWith("global::System", StringComparison.InvariantCulture)).OrderBy(static name => name))
|
||||
{
|
||||
writer.WriteLine($"using {usingDirective};");
|
||||
}
|
||||
|
||||
// Add the other directives, also sorted in the correct order
|
||||
foreach (string usingDirective in usingDirectives.Where(static name => !name.StartsWith("global::System")).OrderBy(static name => name))
|
||||
foreach (string usingDirective in usingDirectives.Where(static name => !name.StartsWith("global::System", StringComparison.InvariantCulture)).OrderBy(static name => name))
|
||||
{
|
||||
writer.WriteLine($"using {usingDirective};");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace ComputeSharp.SourceGeneration.Helpers;
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">The type of keys to use for the cache.</typeparam>
|
||||
/// <typeparam name="TValue">The type of values to store in the cache.</typeparam>
|
||||
public sealed class DynamicCache<TKey, TValue>
|
||||
internal sealed class DynamicCache<TKey, TValue>
|
||||
where TKey : class
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -11,7 +11,7 @@ internal sealed class DxcCompilationException : Exception
|
||||
/// Creates a new <see cref="DxcCompilationException"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="error">The error message produced by the DXC compiler.</param>
|
||||
internal DxcCompilationException(string error)
|
||||
public DxcCompilationException(string error)
|
||||
: base(GetExceptionMessage(error))
|
||||
{
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする