Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ public static IEnumerable<IPropertySymbol> GetAllRequiredProperties(ITypeSymbol
return requiredProperties;
}

/// <summary>
/// Gets required properties that have data source attributes
/// </summary>
public static IEnumerable<IPropertySymbol> GetRequiredPropertiesWithDataSource(ITypeSymbol typeSymbol)
{
return GetAllRequiredProperties(typeSymbol)
.Where(p => HasDataSourceAttribute(p));
}

/// <summary>
/// Gets required properties that don't have data source attributes
/// </summary>
public static IEnumerable<IPropertySymbol> GetRequiredPropertiesWithoutDataSource(ITypeSymbol typeSymbol)
{
return GetAllRequiredProperties(typeSymbol)
.Where(p => !HasDataSourceAttribute(p));
}

private static bool HasDataSourceAttribute(IPropertySymbol property)
{
return property.GetAttributes().Any(attr =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,6 @@ namespace TUnit.Core.SourceGenerator.CodeGenerators.Helpers;
public static class TypedConstantParser
{
private static readonly TypedConstantFormatter _formatter = new();

public static string GetTypedConstantValue(SemanticModel semanticModel,
(TypedConstant typedConstant, AttributeArgumentSyntax a) element, ITypeSymbol? parameterType)
{
// For constant values, use the formatter which handles type conversions properly
if (element.typedConstant.Kind == TypedConstantKind.Primitive)
{
return _formatter.FormatForCode(element.typedConstant, parameterType);
}

var argumentExpression = element.a.Expression;

var newExpression = argumentExpression.Accept(new FullyQualifiedWithGlobalPrefixRewriter(semanticModel))!;

if (parameterType?.TypeKind == TypeKind.Enum &&
(newExpression.IsKind(SyntaxKind.UnaryMinusExpression) || newExpression.IsKind(SyntaxKind.UnaryPlusExpression)))
{
return $"({parameterType.GloballyQualified()})({newExpression})";
}

if (parameterType?.SpecialType == SpecialType.System_Decimal)
{
return $"{newExpression.ToString().TrimEnd('d')}m";
}

if (parameterType is not null
&& element.typedConstant.Type is not null
&& semanticModel.Compilation.ClassifyConversion(element.typedConstant.Type, parameterType) is
{ IsExplicit: true, IsImplicit: false })
{
return $"({parameterType.GloballyQualified()})({newExpression})";
}

return newExpression.ToString();
}

public static string GetFullyQualifiedTypeNameFromTypedConstantValue(TypedConstant typedConstant)
{
Expand Down Expand Up @@ -72,11 +37,6 @@ public static string GetRawTypedConstantValue(TypedConstant typedConstant, IType
return _formatter.FormatForCode(typedConstant, targetType);
}

private static string FormatPrimitive(TypedConstant typedConstant)
{
return FormatPrimitive(typedConstant.Value);
}

public static string FormatPrimitive(object? value)
{
// Check for special floating-point values first
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading