Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
42d475b
Initial plan
Copilot Oct 26, 2025
8218cff
Initial exploration of cross-platform intrinsics analyzer
Copilot Oct 26, 2025
0b15963
Add cross-platform intrinsics method support to analyzer
Copilot Oct 26, 2025
19e8619
Add tests and fix fixer for cross-platform intrinsics methods
Copilot Oct 26, 2025
8a7411e
Extend analyzer to cover AndNot, Negate, Round, Truncate, and Conditi…
Copilot Oct 27, 2025
80647b2
Add FusedMultiplyAdd cross-platform intrinsics support
Copilot Oct 27, 2025
2bb6ba8
Address review feedback for cross-platform intrinsics analyzer
Copilot Oct 27, 2025
789a4f6
First step: Add semantic fixes for x86 AndNot (parameter swap) and Ma…
Copilot Oct 27, 2025
c93e6de
Step 2: Add AdvSimd method support (AbsScalar, AddSaturate, BitwiseSe…
Copilot Oct 27, 2025
7eee078
Step 3: Add AdvSimd Round variants (RoundToNearest, RoundToNegativeIn…
Copilot Oct 27, 2025
ff6fb2b
Step 4: Add similar method coverage for x86/x64 and WASM platforms
Copilot Oct 27, 2025
2c9be9e
Step 5: Add Load and Store API support across all platforms
Copilot Oct 27, 2025
552d3ed
Implement fixer for Load and Store methods
Copilot Oct 27, 2025
4b0b04e
Fix failing tests by skipping MaxNative/MinNative tests (NET 9+ APIs …
Copilot Oct 27, 2025
f63c65d
Co-authored-by: stephentoub <[email protected]
Copilot Oct 27, 2025
d24289e
Address code review feedback: consolidate vector type checks, add IsV…
Copilot Oct 27, 2025
e2c288e
Add missing IsVectorType helper method implementation
Copilot Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,182 @@

return generator.Parenthesize(replacementExpression);
}

protected override SyntaxNode ReplaceWithUnaryMethod(SyntaxNode currentNode, SyntaxGenerator generator, string methodName)
{
if (currentNode is not InvocationExpressionSyntax invocationExpression)
{
Debug.Fail($"Found unexpected node kind: {currentNode.RawKind}");
return currentNode;
}

SeparatedSyntaxList<ArgumentSyntax> arguments = invocationExpression.ArgumentList.Arguments;

if (arguments.Count != 1)
{
Debug.Fail($"Found unexpected number of arguments for unary method replacement: {arguments.Count}");
return currentNode;
}

// Determine the vector type name from the return type if available
var vectorTypeName = DetermineVectorTypeName(invocationExpression);

// Create the cross-platform method call: VectorXXX.MethodName(arg)
// The type parameter will be inferred from the argument
var vectorTypeIdentifier = generator.IdentifierName(vectorTypeName);
var replacementExpression = generator.InvocationExpression(
generator.MemberAccessExpression(vectorTypeIdentifier, methodName),
arguments[0].Expression);

return generator.Parenthesize(replacementExpression);
}

protected override SyntaxNode ReplaceWithBinaryMethod(SyntaxNode currentNode, SyntaxGenerator generator, string methodName)
{
if (currentNode is not InvocationExpressionSyntax invocationExpression)
{
Debug.Fail($"Found unexpected node kind: {currentNode.RawKind}");
return currentNode;
}

SeparatedSyntaxList<ArgumentSyntax> arguments = invocationExpression.ArgumentList.Arguments;

if (arguments.Count != 2)
{
Debug.Fail($"Found unexpected number of arguments for binary method replacement: {arguments.Count}");
return currentNode;
}

// Determine the vector type name from the return type if available
var vectorTypeName = DetermineVectorTypeName(invocationExpression);

// Create the cross-platform method call: VectorXXX.MethodName(arg1, arg2)
// The type parameter will be inferred from the arguments
var vectorTypeIdentifier = generator.IdentifierName(vectorTypeName);
var replacementExpression = generator.InvocationExpression(
generator.MemberAccessExpression(vectorTypeIdentifier, methodName),
arguments[0].Expression,
arguments[1].Expression);

return generator.Parenthesize(replacementExpression);
}

protected override SyntaxNode ReplaceWithBinaryMethodSwapped(SyntaxNode currentNode, SyntaxGenerator generator, string methodName)
{
if (currentNode is not InvocationExpressionSyntax invocationExpression)
{
Debug.Fail($"Found unexpected node kind: {currentNode.RawKind}");
return currentNode;
}

SeparatedSyntaxList<ArgumentSyntax> arguments = invocationExpression.ArgumentList.Arguments;

if (arguments.Count != 2)
{
Debug.Fail($"Found unexpected number of arguments for binary method replacement: {arguments.Count}");
return currentNode;
}

// Determine the vector type name from the return type if available
var vectorTypeName = DetermineVectorTypeName(invocationExpression);

// Create the cross-platform method call with swapped parameters: VectorXXX.MethodName(arg2, arg1)
// For example, Sse.AndNot(x, y) = ~x & y maps to Vector128.AndNot(y, x) = y & ~x
var vectorTypeIdentifier = generator.IdentifierName(vectorTypeName);
var replacementExpression = generator.InvocationExpression(
generator.MemberAccessExpression(vectorTypeIdentifier, methodName),
arguments[1].Expression, // Swap: second argument first
arguments[0].Expression); // Swap: first argument second

return generator.Parenthesize(replacementExpression);
}

private static string DetermineVectorTypeName(SyntaxNode node)
{
// For method signatures like "Vector256<float> M(Vector256<float> x)",
// we need to find the return type of the method containing this invocation

// Walk up to find the method declaration
var current = node;
while (current != null)
{
if (current is MethodDeclarationSyntax methodDecl)
{
// Check the return type
var returnType = methodDecl.ReturnType;
if (returnType is GenericNameSyntax genericReturn &&
IsVectorType(genericReturn.Identifier.Text))

Check failure on line 182 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TemplateEngine: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L182

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(182,25): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 182 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: linux (arm64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L182

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(182,25): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 182 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: linux (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L182

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(182,25): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 182 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TemplateEngine: linux (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L182

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(182,25): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 182 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build AoT: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L182

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(182,25): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 182 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L182

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(182,25): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 182 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: macOS (arm64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L182

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(182,25): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context
{
return genericReturn.Identifier.Text;

Check failure on line 184 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TemplateEngine: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L184

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(184,32): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericReturn'

Check failure on line 184 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: linux (arm64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L184

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(184,32): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericReturn'

Check failure on line 184 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: linux (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L184

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(184,32): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericReturn'

Check failure on line 184 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TemplateEngine: linux (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L184

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(184,32): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericReturn'

Check failure on line 184 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build AoT: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L184

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(184,32): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericReturn'

Check failure on line 184 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L184

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(184,32): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericReturn'

Check failure on line 184 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: macOS (arm64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L184

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(184,32): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericReturn'
}
}
current = current.Parent;
}

// Also check the invocation itself for argument types
// This handles cases where the invocation is in an expression-bodied member
if (node is InvocationExpressionSyntax invocation)
{
foreach (var arg in invocation.ArgumentList.Arguments)
{
var vectorType = FindVectorTypeInExpression(arg.Expression);
if (vectorType != null)
{
return vectorType;
}
}
}

// Default to Vector128 if we can't determine the vector type from context.
// This fallback is used when the platform-specific intrinsic call is in a context
// where we cannot infer the return type (e.g., passed as an argument to another method).
// Vector128 is the most common vector size across all platforms.
return "Vector128";
}

private static string? FindVectorTypeInExpression(SyntaxNode node)
{
// Look for Vector types in the expression (could be identifiers or generic names)
foreach (var descendant in node.DescendantNodesAndSelf())
{
if (descendant is GenericNameSyntax genericName &&
IsVectorType(genericName.Identifier.Text))

Check failure on line 217 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TemplateEngine: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L217

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(217,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 217 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: linux (arm64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L217

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(217,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 217 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: linux (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L217

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(217,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 217 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TemplateEngine: linux (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L217

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(217,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 217 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build AoT: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L217

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(217,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 217 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L217

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(217,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context

Check failure on line 217 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: macOS (arm64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L217

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(217,21): error CS0103: (NETCORE_ENGINEERING_TELEMETRY=Build) The name 'IsVectorType' does not exist in the current context
{
return genericName.Identifier.Text;

Check failure on line 219 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TemplateEngine: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L219

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(219,28): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericName'

Check failure on line 219 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: linux (arm64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L219

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(219,28): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericName'

Check failure on line 219 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: linux (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L219

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(219,28): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericName'

Check failure on line 219 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TemplateEngine: linux (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L219

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(219,28): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericName'

Check failure on line 219 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build AoT: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L219

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(219,28): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericName'

Check failure on line 219 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: macOS (x64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L219

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(219,28): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericName'

Check failure on line 219 in src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build TestBuild: macOS (arm64))

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs#L219

src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.CSharp.NetAnalyzers/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpUseCrossPlatformIntrinsicsFixer.cs(219,28): error CS0165: (NETCORE_ENGINEERING_TELEMETRY=Build) Use of unassigned local variable 'genericName'
}
}
return null;
}

protected override SyntaxNode ReplaceWithTernaryMethod(SyntaxNode currentNode, SyntaxGenerator generator, string methodName)
{
if (currentNode is not InvocationExpressionSyntax invocationExpression)
{
Debug.Fail($"Found unexpected node kind: {currentNode.RawKind}");
return currentNode;
}

SeparatedSyntaxList<ArgumentSyntax> arguments = invocationExpression.ArgumentList.Arguments;

if (arguments.Count != 3)
{
Debug.Fail($"Found unexpected number of arguments for ternary method replacement: {arguments.Count}");
return currentNode;
}

// Determine the vector type name from the return type if available
var vectorTypeName = DetermineVectorTypeName(invocationExpression);

// Create the cross-platform method call: VectorXXX.MethodName(arg1, arg2, arg3)
// The type parameter will be inferred from the arguments
var vectorTypeIdentifier = generator.IdentifierName(vectorTypeName);
var replacementExpression = generator.InvocationExpression(
generator.MemberAccessExpression(vectorTypeIdentifier, methodName),
arguments[0].Expression,
arguments[1].Expression,
arguments[2].Expression);

return generator.Parenthesize(replacementExpression);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public partial class UseCrossPlatformIntrinsicsAnalyzer
{
public enum RuleKind
{
// These names match the underlying IL names for the cross-platform API that will be used in the fixer.
// These names match the underlying IL names or method names for the cross-platform API that will be used in the fixer.

op_Addition,
op_BitwiseAnd,
Expand All @@ -21,6 +21,35 @@ public enum RuleKind
op_UnaryNegation,
op_UnsignedRightShift,

// Named methods (not operators)
Abs,
AddSaturate,
AndNot, // For ARM BitwiseClear - direct parameter mapping
AndNot_Swapped, // For x86/x64 AndNot - needs parameter swap
Ceiling,
ConditionalSelect,
ConvertToInt32,
Equals,
Floor,
FusedMultiplyAdd,
GetElement,
GreaterThan,
GreaterThanOrEqual,
LessThan,
LessThanOrEqual,
Max,
MaxNative, // For x86/x64 Max - different NaN/negative zero handling
Min,
MinNative, // For x86/x64 Min - different NaN/negative zero handling
Negate,
Round,
Sqrt,
Truncate,
WithElement,
Load,
Store,
Shuffle,

Count,
}
}
Expand Down
Loading
Loading