Skip to content

Commit 12f8841

Browse files
Support generic list in DataFactoryExpression (Azure#32527)
* Support generic list * PR fb * update docs * Support nullable values and reference type generics * API * Remove IReadOnlyList and clean up * Update docs * Fix deserialization of expression list * Remove unnecessary AsEnumerable call * Remove use of ChangeTrackingList as we do not leverage the IsCollectionDefined method anyway * Remove unnecessary shared source; add target for net6.0 * API * Fix tests * Remove LiteralInternal * PR fb
1 parent 7ac3f2e commit 12f8841

10 files changed

+513
-145
lines changed

sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.net461.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Azure.Core.Expressions.DataFactory
22
{
33
public sealed partial class DataFactoryExpression<T>
44
{
5-
public DataFactoryExpression(T literal) { }
5+
public DataFactoryExpression(T? literal) { }
66
public bool HasLiteral { get { throw null; } }
77
public T? Literal { get { throw null; } }
88
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]

sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.net5.0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Azure.Core.Expressions.DataFactory
22
{
33
public sealed partial class DataFactoryExpression<T>
44
{
5-
public DataFactoryExpression(T literal) { }
5+
public DataFactoryExpression(T? literal) { }
66
public bool HasLiteral { get { throw null; } }
77
public T? Literal { get { throw null; } }
88
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Azure.Core.Expressions.DataFactory
2+
{
3+
public sealed partial class DataFactoryExpression<T>
4+
{
5+
public DataFactoryExpression(T? literal) { }
6+
public bool HasLiteral { get { throw null; } }
7+
public T? Literal { get { throw null; } }
8+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
9+
public override bool Equals(object? obj) { throw null; }
10+
public static Azure.Core.Expressions.DataFactory.DataFactoryExpression<T> FromExpression(string expression) { throw null; }
11+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
12+
public override int GetHashCode() { throw null; }
13+
public static implicit operator Azure.Core.Expressions.DataFactory.DataFactoryExpression<T> (T literal) { throw null; }
14+
public override string? ToString() { throw null; }
15+
}
16+
}

sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netcoreapp2.1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Azure.Core.Expressions.DataFactory
22
{
33
public sealed partial class DataFactoryExpression<T>
44
{
5-
public DataFactoryExpression(T literal) { }
5+
public DataFactoryExpression(T? literal) { }
66
public bool HasLiteral { get { throw null; } }
77
public T? Literal { get { throw null; } }
88
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]

sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Azure.Core.Expressions.DataFactory
22
{
33
public sealed partial class DataFactoryExpression<T>
44
{
5-
public DataFactoryExpression(T literal) { }
5+
public DataFactoryExpression(T? literal) { }
66
public bool HasLiteral { get { throw null; } }
77
public T? Literal { get { throw null; } }
88
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]

sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageTags>azure;datafactory</PackageTags>
88
<Nullable>enable</Nullable>
99
<DefineConstants>$(DefineConstants);AZURE_NULLABLE;HAS_INTERNALS_VISIBLE_CORE</DefineConstants>
10-
<TargetFrameworks>$(RequiredTargetFrameworks);net461;netcoreapp2.1;net5.0</TargetFrameworks>
10+
<TargetFrameworks>$(RequiredTargetFrameworks);net461;netcoreapp2.1;net5.0;net6.0</TargetFrameworks>
1111
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1212
<EnableClientSdkAnalyzers>true</EnableClientSdkAnalyzers>
1313
<EnableBannedApiAnalyzers>false</EnableBannedApiAnalyzers>
@@ -16,8 +16,6 @@
1616
to give customers time to migrate without losing perf optimizations
1717
-->
1818
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
19-
<!--<IncludeGeneratorSharedCode>true</IncludeGeneratorSharedCode>
20-
<IncludeOperationsSharedSource>true</IncludeOperationsSharedSource>-->
2119
</PropertyGroup>
2220

2321
<ItemGroup>
@@ -26,9 +24,6 @@
2624

2725
<ItemGroup>
2826
<Compile Include="$(AutoRestSharedCodeDirectory)IUtf8JsonSerializable.cs" LinkBase="Shared\AutoRest" />
29-
<Compile Include="$(AutoRestSharedCodeDirectory)Optional.cs" LinkBase="Shared\AutoRest" />
30-
<Compile Include="$(AutoRestSharedCodeDirectory)ChangeTrackingDictionary.cs" LinkBase="Shared\AutoRest" />
31-
<Compile Include="$(AutoRestSharedCodeDirectory)ChangeTrackingList.cs" LinkBase="Shared\AutoRest" />
3227
<Compile Include="$(AutoRestSharedCodeDirectory)Utf8JsonWriterExtensions.cs" LinkBase="Shared\AutoRest" />
3328
<Compile Include="$(AutoRestSharedCodeDirectory)TypeFormatters.cs" LinkBase="Shared\AutoRest" />
3429
<Compile Include="$(AutoRestSharedCodeDirectory)JsonElementExtensions.cs" LinkBase="Shared\AutoRest" />

sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryExpression.Serialization.cs

Lines changed: 0 additions & 60 deletions
This file was deleted.

sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryExpression.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,30 @@
44
using System;
55
using System.ComponentModel;
66
using System.Linq;
7-
using System.Security;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
89

910
namespace Azure.Core.Expressions.DataFactory
1011
{
1112
/// <summary>
1213
/// A class representing either a primitive value or an expression.
1314
/// For details on DataFactoryExpressions see https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#expressions.
1415
/// </summary>
15-
/// <typeparam name="T"> Can be one of <see cref="string"/>, <see cref="bool"/>, <see cref="int"/>, <see cref="double"/>, <see cref="Array"/>. </typeparam>
16+
/// <typeparam name="T"> Can be one of <see cref="string"/>, <see cref="bool"/>, <see cref="int"/>, <see cref="double"/>, <see cref="Array"/>, or <see cref="IList{TElement}"/>.</typeparam>
1617
#pragma warning disable SA1649 // File name should match first type name
17-
public sealed partial class DataFactoryExpression<T> : IUtf8JsonSerializable
18+
[JsonConverter(typeof(DataFactoryExpressionJsonConverter))]
19+
public sealed class DataFactoryExpression<T>
1820
#pragma warning restore SA1649 // File name should match first type name
1921
{
20-
private string? _type;
21-
private T? _literal;
22-
private string? _expression;
22+
internal string? Type { get; }
23+
private readonly T? _literal;
24+
internal string? Expression { get; }
2325

2426
/// <summary>
2527
/// Initializes a new instance of DataFactoryExpression with a literal value.
2628
/// </summary>
2729
/// <param name="literal"> The literal value. </param>
28-
public DataFactoryExpression(T literal)
30+
public DataFactoryExpression(T? literal)
2931
{
3032
HasLiteral = true;
3133
_literal = literal;
@@ -52,8 +54,8 @@ public T? Literal
5254

5355
internal DataFactoryExpression(string expression, string type)
5456
{
55-
_type = type;
56-
_expression = expression;
57+
Type = type;
58+
Expression = expression;
5759
}
5860

5961
/// <inheritdoc/>
@@ -70,7 +72,7 @@ internal DataFactoryExpression(string expression, string type)
7072
return _literal?.ToString();
7173
}
7274
}
73-
return _expression!;
75+
return Expression!;
7476
}
7577

7678
/// <summary>

0 commit comments

Comments
 (0)