Pow Sqrt ....
This commit is contained in:
@@ -111,17 +111,16 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
var pars = method.Parameters;
|
||||
if (pars.Length != 2) continue;
|
||||
|
||||
var leftType = pars[0].Type as INamedTypeSymbol;
|
||||
var rightType = pars[1].Type as INamedTypeSymbol;
|
||||
var returnType = method.ReturnType as INamedTypeSymbol;
|
||||
if (leftType == null || rightType == null || returnType == null) continue;
|
||||
if (pars[0].Type is not INamedTypeSymbol leftType
|
||||
|| pars[1].Type is not INamedTypeSymbol rightType
|
||||
|| method.ReturnType is not INamedTypeSymbol returnType) continue;
|
||||
|
||||
if (!unitTypes.Contains(leftType, SymbolEqualityComparer.Default) ||
|
||||
!unitTypes.Contains(rightType, SymbolEqualityComparer.Default) ||
|
||||
!unitTypes.Contains(returnType, SymbolEqualityComparer.Default))
|
||||
continue;
|
||||
|
||||
string? coeffField = null;
|
||||
string coeffField = null;
|
||||
foreach (var attr in method.GetAttributes())
|
||||
{
|
||||
if (attr.AttributeClass?.Name == "OperatorsGeneratorAttribute" ||
|
||||
@@ -142,7 +141,7 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
result.Add(new OperatorInfo(opSymbol, leftType, rightType, returnType, coeffField, containingType));
|
||||
}
|
||||
}
|
||||
return result.ToImmutableArray();
|
||||
return [.. result];
|
||||
}
|
||||
|
||||
private static void GenerateOperatorTests(SourceProductionContext spc, ImmutableArray<OperatorInfo> operators)
|
||||
@@ -397,7 +396,7 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
CollectTypesRecursive(childNs, result, targetNamespacePrefix);
|
||||
}
|
||||
|
||||
private static IPropertySymbol? GetBaseUnitProperty(ITypeSymbol type)
|
||||
private static IPropertySymbol GetBaseUnitProperty(ITypeSymbol type)
|
||||
{
|
||||
foreach (var member in type.GetMembers())
|
||||
{
|
||||
@@ -407,13 +406,13 @@ public class TestsGenerator : IIncrementalGenerator
|
||||
return null;
|
||||
}
|
||||
|
||||
private readonly struct OperatorInfo(string symbol, ITypeSymbol left, ITypeSymbol right, ITypeSymbol ret, string? coeff, ITypeSymbol containing)
|
||||
private readonly struct OperatorInfo(string symbol, ITypeSymbol left, ITypeSymbol right, ITypeSymbol ret, string coeff, ITypeSymbol containing)
|
||||
{
|
||||
public string OperatorSymbol { get; } = symbol;
|
||||
public ITypeSymbol LeftType { get; } = left;
|
||||
public ITypeSymbol RightType { get; } = right;
|
||||
public ITypeSymbol ReturnType { get; } = ret;
|
||||
public string? CoefficientField { get; } = coeff;
|
||||
public string CoefficientField { get; } = coeff;
|
||||
public ITypeSymbol ContainingType { get; } = containing;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user