Repository navigation
Discover AOT converters from method data source return types #7547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8837aa1
b247ff7
a1a148f
dc0dc22
a8babf9
b51a0c4
5ecf58d
d6d4d3f
ec62016
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ | |
| private const string InstanceMethodDataSourceAttributeName = "global::TUnit.Core.InstanceMethodDataSourceAttribute"; | ||
|
|
||
| private static readonly DiagnosticDescriptor GenerationErrorDescriptor = new( | ||
| "TUNIT0999", | ||
|
Check warning on line 29 in src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs
|
||
| "Source Generation Error", | ||
| "Failed to generate test metadata for {0}.{1}: {2}", | ||
| "TUnit", | ||
|
|
@@ -7700,7 +7700,7 @@ | |
| if (!inferredTypes.ContainsKey(name)) | ||
| { | ||
| inferredTypes[name] = compilation.GetSpecialType(SpecialType.System_Object); | ||
| } | ||
|
Check warning on line 7703 in src/TUnit.Core.SourceGenerator/Generators/TestMetadataGenerator.cs
|
||
| } | ||
| } | ||
|
|
||
|
|
@@ -8361,7 +8361,7 @@ | |
| /// resolution on the target type would discard a base overload once a derived one is applicable | ||
| /// (https://github.com/thomhurst/TUnit/issues/7202). | ||
| /// </summary> | ||
| private static ISymbol? ResolveMethodDataSourceMember(ITypeSymbol targetType, string memberName, AttributeData attr, Compilation compilation) | ||
| internal static ISymbol? ResolveMethodDataSourceMember(ITypeSymbol targetType, string memberName, AttributeData attr, Compilation compilation) | ||
| { | ||
| var argumentsProperty = attr.NamedArguments.FirstOrDefault(x => x.Key == "Arguments"); | ||
| var arguments = argumentsProperty is { Key: not null, Value: { IsNull: false, Kind: TypedConstantKind.Array } } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| // <auto-generated/> | ||
| #pragma warning disable | ||
|
|
||
| #nullable enable | ||
| using System; | ||
| using TUnit.Core.Converters; | ||
| namespace TUnit.Generated | ||
| { | ||
| internal sealed class AotConverter_0 : IAotConverter | ||
| { | ||
| public Type SourceType => typeof(global::ClassValue); | ||
| public Type TargetType => typeof(int); | ||
| public object? Convert(object? value) | ||
| { | ||
| if (value == null) return null; | ||
| if (value is int targetTypedValue) | ||
| { | ||
| return targetTypedValue; | ||
| } | ||
| if (value is global::ClassValue sourceTypedValue) | ||
| { | ||
| int converted = sourceTypedValue; | ||
| return converted; | ||
| } | ||
| return value; // Return original value if type doesn't match | ||
| } | ||
| } | ||
| internal sealed class AotConverter_1 : IAotConverter | ||
| { | ||
| public Type SourceType => typeof(global::ScalarValue); | ||
| public Type TargetType => typeof(int); | ||
| public object? Convert(object? value) | ||
| { | ||
| if (value == null) return null; | ||
| if (value is int targetTypedValue) | ||
| { | ||
| return targetTypedValue; | ||
| } | ||
| if (value is global::ScalarValue sourceTypedValue) | ||
| { | ||
| int converted = sourceTypedValue; | ||
| return converted; | ||
| } | ||
| return value; // Return original value if type doesn't match | ||
| } | ||
| } | ||
| internal sealed class AotConverter_2 : IAotConverter | ||
| { | ||
| public Type SourceType => typeof(global::TupleValue); | ||
| public Type TargetType => typeof(global::System.ValueTuple<int, int>); | ||
| public object? Convert(object? value) | ||
| { | ||
| if (value == null) return null; | ||
| if (value is global::System.ValueTuple<int, int> targetTypedValue) | ||
| { | ||
| return targetTypedValue; | ||
| } | ||
| if (value is global::TupleValue sourceTypedValue) | ||
| { | ||
| global::System.ValueTuple<int, int> converted = (global::System.ValueTuple<int, int>)sourceTypedValue; | ||
| return converted; | ||
| } | ||
| return value; // Return original value if type doesn't match | ||
| } | ||
| } | ||
| internal sealed class AotConverter_3 : IAotConverter | ||
| { | ||
| public Type SourceType => typeof(global::ArrayValue); | ||
| public Type TargetType => typeof(int); | ||
| public object? Convert(object? value) | ||
| { | ||
| if (value == null) return null; | ||
| if (value is int targetTypedValue) | ||
| { | ||
| return targetTypedValue; | ||
| } | ||
| if (value is global::ArrayValue sourceTypedValue) | ||
| { | ||
| int converted = sourceTypedValue; | ||
| return converted; | ||
| } | ||
| return value; // Return original value if type doesn't match | ||
| } | ||
| } | ||
| internal sealed class AotConverter_4 : IAotConverter | ||
| { | ||
| public Type SourceType => typeof(global::AsyncValue); | ||
| public Type TargetType => typeof(int); | ||
| public object? Convert(object? value) | ||
| { | ||
| if (value == null) return null; | ||
| if (value is int targetTypedValue) | ||
| { | ||
| return targetTypedValue; | ||
| } | ||
| if (value is global::AsyncValue sourceTypedValue) | ||
| { | ||
| int converted = (int)sourceTypedValue; | ||
| return converted; | ||
| } | ||
| return value; // Return original value if type doesn't match | ||
| } | ||
| } | ||
| internal sealed class AotConverter_5 : IAotConverter | ||
| { | ||
| public Type SourceType => typeof(global::ParameterValue); | ||
| public Type TargetType => typeof(int); | ||
| public object? Convert(object? value) | ||
| { | ||
| if (value == null) return null; | ||
| if (value is int targetTypedValue) | ||
| { | ||
| return targetTypedValue; | ||
| } | ||
| if (value is global::ParameterValue sourceTypedValue) | ||
| { | ||
| int converted = sourceTypedValue; | ||
| return converted; | ||
| } | ||
| return value; // Return original value if type doesn't match | ||
| } | ||
| } | ||
| internal static partial class TUnit_ConverterRegistration | ||
| { | ||
| static readonly int _r_AotConverter_0 = global::TUnit.Core.Converters.AotConverterRegistry.Register(new AotConverter_0()); | ||
| static readonly int _r_AotConverter_1 = global::TUnit.Core.Converters.AotConverterRegistry.Register(new AotConverter_1()); | ||
| static readonly int _r_AotConverter_2 = global::TUnit.Core.Converters.AotConverterRegistry.Register(new AotConverter_2()); | ||
| static readonly int _r_AotConverter_3 = global::TUnit.Core.Converters.AotConverterRegistry.Register(new AotConverter_3()); | ||
| static readonly int _r_AotConverter_4 = global::TUnit.Core.Converters.AotConverterRegistry.Register(new AotConverter_4()); | ||
| static readonly int _r_AotConverter_5 = global::TUnit.Core.Converters.AotConverterRegistry.Register(new AotConverter_5()); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.