Skip to content

Commit acb51ab

Browse files
authored
Remove obsolete conditions from Search (#15268)
Fixes #14096 to simplify the code for upcoming changes.
1 parent 37c15b5 commit acb51ab

38 files changed

+0
-1162
lines changed

sdk/search/Azure.Search.Documents/Directory.Build.props

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,10 @@
1010
<UseAzureCoreExperimentalSpatial Condition="'$(UseAzureCoreExperimentalSpatial)' == ''">$(UseAzureCoreExperimental)</UseAzureCoreExperimentalSpatial>
1111
<DefineConstants Condition="'$(UseAzureCoreExperimentalSpatial)' == 'true'">EXPERIMENTAL_SPATIAL;$(DefineConstants)</DefineConstants>
1212

13-
<!-- Use Azure.Core's ObjectSerializer features -->
14-
<UseAzureCoreSerializer Condition="'$(UseAzureCoreSerializer)' == ''">true</UseAzureCoreSerializer>
15-
<DefineConstants Condition="'$(UseAzureCoreSerializer)' == 'true'">EXPERIMENTAL_SERIALIZER;$(DefineConstants)</DefineConstants>
16-
1713
<!-- Use Azure.Core.Experimental's DynamicData features (stubbed out in Search for now) -->
1814
<UseAzureCoreExperimentalDynamic Condition="'$(UseAzureCoreExperimentalDynamic)' == ''">$(UseAzureCoreExperimental)</UseAzureCoreExperimentalDynamic>
1915
<DefineConstants Condition="'$(UseAzureCoreExperimentalDynamic)' == 'true'">EXPERIMENTAL_DYNAMIC;$(DefineConstants)</DefineConstants>
2016

21-
<UseFieldBuilder Condition="'$(UseFieldBuilder)' == '' AND '$(UseAzureCoreSerializer)' == 'true'">true</UseFieldBuilder>
22-
<DefineConstants Condition="'$(UseFieldBuilder)' == 'true'">EXPERIMENTAL_FIELDBUILDER;$(DefineConstants)</DefineConstants>
23-
2417
<!-- Use a Package or Project reference to Azure.Core.Experimental -->
2518
<AddExperimentalReference Condition="('$(UseAzureCoreExperimentalSpatial)' == 'true') OR ('$(UseAzureCoreExperimentalDynamic)' == 'true')">true</AddExperimentalReference>
2619
<UseExperimentalProjectReference Condition="'$(UseExperimentalProjectReference)' == ''">$(UseProjectReferenceToAzureClients)</UseExperimentalProjectReference>

sdk/search/Azure.Search.Documents/src/Azure.Search.Documents.csproj

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@
1616
<NoWarn>$(NoWarn);AZC0007;AZC0004;AZC0001</NoWarn>
1717
</PropertyGroup>
1818

19-
<!-- Conditionally compile FieldBuilder and related source -->
20-
<ItemGroup Condition="'$(UseFieldBuilder)' != 'true'">
21-
<Compile Remove="Indexes\FieldBuilder.cs" />
22-
<Compile Remove="Indexes\FieldBuilderIgnoreAttribute.cs" />
23-
<Compile Remove="Indexes\ISearchFieldAttribute.cs" />
24-
<Compile Remove="Indexes\SearchableFieldAttribute.cs" />
25-
<Compile Remove="Indexes\SimpleFieldAttribute.cs" />
26-
</ItemGroup>
27-
2819
<!-- Pull in Shared Source from Azure.Core -->
2920
<ItemGroup>
3021
<Compile Include="$(AzureCoreSharedSources)Argument.cs" Link="Shared\%(RecursiveDir)\%(Filename)%(Extension)" />

sdk/search/Azure.Search.Documents/src/Indexes/FieldBuilder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
using System.Linq;
1010
using System.Reflection;
1111
using Azure.Core;
12-
#if EXPERIMENTAL_SERIALIZER
1312
using Azure.Core.Serialization;
14-
#endif
1513
using Azure.Search.Documents.Indexes.Models;
1614
#if EXPERIMENTAL_SPATIAL
1715
using Azure.Core.Spatial;

sdk/search/Azure.Search.Documents/src/Indexes/Models/LexicalAnalyzerName.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace Azure.Search.Documents.Indexes.Models
55
{
66
public readonly partial struct LexicalAnalyzerName
77
{
8-
#if EXPERIMENTAL_FIELDBUILDER
98
#pragma warning disable CA1034 // Nested types should not be visible
109
/// <summary>
1110
/// The values of all declared <see cref="LexicalAnalyzerName"/> properties as string constants.
@@ -201,6 +200,5 @@ public static class Values
201200
public const string Whitespace = LexicalAnalyzerName.WhitespaceValue;
202201
}
203202
#pragma warning restore CA1034 // Nested types should not be visible
204-
#endif
205203
}
206204
}

sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchIndex.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public SearchIndex(string name, IEnumerable<SearchField> fields)
7575
/// </summary>
7676
public IList<CharFilter> CharFilters { get; }
7777

78-
#if EXPERIMENTAL_FIELDBUILDER
7978
/// <summary>
8079
/// Gets or sets the fields in the index.
8180
/// Use <see cref="FieldBuilder"/> to define fields based on a model class,
@@ -126,44 +125,6 @@ public SearchIndex(string name, IEnumerable<SearchField> fields)
126125
/// };
127126
/// </code>
128127
/// </example>
129-
#else
130-
/// <summary>
131-
/// Gets or sets the fields in the index.
132-
/// Use <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref="ComplexField"/> to manually define fields.
133-
/// Index fields have many constraints that are not validated with <see cref="SearchField"/> until the index is created on the server.
134-
/// </summary>
135-
/// <example>
136-
/// You can create fields manually using helper classes:
137-
/// <code snippet="Snippet:Azure_Search_Tests_Samples_Readme_CreateManualIndex_New_SearchIndex">
138-
/// SearchIndex index = new SearchIndex(&quot;hotels&quot;)
139-
/// {
140-
/// Fields =
141-
/// {
142-
/// new SimpleField(&quot;hotelId&quot;, SearchFieldDataType.String) { IsKey = true, IsFilterable = true, IsSortable = true },
143-
/// new SearchableField(&quot;hotelName&quot;) { IsFilterable = true, IsSortable = true },
144-
/// new SearchableField(&quot;description&quot;) { AnalyzerName = LexicalAnalyzerName.EnLucene },
145-
/// new SearchableField(&quot;tags&quot;, collection: true) { IsFilterable = true, IsFacetable = true },
146-
/// new ComplexField(&quot;address&quot;)
147-
/// {
148-
/// Fields =
149-
/// {
150-
/// new SearchableField(&quot;streetAddress&quot;),
151-
/// new SearchableField(&quot;city&quot;) { IsFilterable = true, IsSortable = true, IsFacetable = true },
152-
/// new SearchableField(&quot;stateProvince&quot;) { IsFilterable = true, IsSortable = true, IsFacetable = true },
153-
/// new SearchableField(&quot;country&quot;) { IsFilterable = true, IsSortable = true, IsFacetable = true },
154-
/// new SearchableField(&quot;postalCode&quot;) { IsFilterable = true, IsSortable = true, IsFacetable = true }
155-
/// }
156-
/// }
157-
/// },
158-
/// Suggesters =
159-
/// {
160-
/// // Suggest query terms from the hotelName field.
161-
/// new SearchSuggester(&quot;sg&quot;, &quot;hotelName&quot;)
162-
/// }
163-
/// };
164-
/// </code>
165-
/// </example>
166-
#endif
167128
public IList<SearchField> Fields
168129
{
169130
get => _fields;

sdk/search/Azure.Search.Documents/src/Indexes/SearchIndexClient.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
using System.Threading.Tasks;
99
using Azure.Core;
1010
using Azure.Core.Pipeline;
11-
#if EXPERIMENTAL_SERIALIZER
1211
using Azure.Core.Serialization;
13-
#endif
1412
using Azure.Search.Documents.Indexes.Models;
1513

1614
namespace Azure.Search.Documents.Indexes
@@ -23,9 +21,7 @@ public class SearchIndexClient
2321
private readonly HttpPipeline _pipeline;
2422
private readonly ClientDiagnostics _clientDiagnostics;
2523
private readonly SearchClientOptions.ServiceVersion _version;
26-
#if EXPERIMENTAL_SERIALIZER
2724
private readonly ObjectSerializer _serializer;
28-
#endif
2925

3026
private ServiceRestClient _serviceClient;
3127
private IndexesRestClient _indexesClient;
@@ -76,9 +72,7 @@ public SearchIndexClient(
7672

7773
options ??= new SearchClientOptions();
7874
Endpoint = endpoint;
79-
#if EXPERIMENTAL_SERIALIZER
8075
_serializer = options.Serializer;
81-
#endif
8276
_clientDiagnostics = new ClientDiagnostics(options);
8377
_pipeline = options.Build(credential);
8478
_version = options.Version;
@@ -146,9 +140,7 @@ public virtual SearchClient GetSearchClient(string indexName)
146140
return new SearchClient(
147141
Endpoint,
148142
indexName,
149-
#if EXPERIMENTAL_SERIALIZER
150143
_serializer,
151-
#endif
152144
_pipeline,
153145
_clientDiagnostics,
154146
_version);

sdk/search/Azure.Search.Documents/src/Models/IndexDocumentsAction{T}.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Azure.Core;
11-
#if EXPERIMENTAL_SERIALIZER
1211
using Azure.Core.Serialization;
13-
#endif
1412

1513
#pragma warning disable SA1402 // File may only contain a single type
1614

@@ -79,9 +77,7 @@ public IndexDocumentsAction(IndexActionType type, T doc)
7977
/// <returns>A task representing the serialization.</returns>
8078
internal async Task SerializeAsync(
8179
Utf8JsonWriter writer,
82-
#if EXPERIMENTAL_SERIALIZER
8380
ObjectSerializer serializer,
84-
#endif
8581
JsonSerializerOptions options,
8682
bool async,
8783
CancellationToken cancellationToken)
@@ -97,7 +93,6 @@ internal async Task SerializeAsync(
9793
// HACK: Serialize the user's model, parse it, and then write each
9894
// of its properties as if they were our own.
9995
byte[] json;
100-
#if EXPERIMENTAL_SERIALIZER
10196
if (serializer != null)
10297
{
10398
using MemoryStream stream = new MemoryStream();
@@ -113,11 +108,8 @@ internal async Task SerializeAsync(
113108
}
114109
else
115110
{
116-
#endif
117111
json = JsonSerializer.SerializeToUtf8Bytes<T>(Document, options);
118-
#if EXPERIMENTAL_SERIALIZER
119112
}
120-
#endif
121113
using JsonDocument nested = JsonDocument.Parse(json);
122114
foreach (JsonProperty property in nested.RootElement.EnumerateObject())
123115
{

sdk/search/Azure.Search.Documents/src/Models/IndexDocumentsBatch{T}.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Azure.Core;
11-
#if EXPERIMENTAL_SERIALIZER
1211
using Azure.Core.Serialization;
13-
#endif
1412

1513
#pragma warning disable SA1402 // File may only contain a single type
1614

@@ -77,9 +75,7 @@ internal IndexDocumentsBatch(IndexActionType type, IEnumerable<T> documents)
7775
/// <returns>A task representing the serialization.</returns>
7876
internal async Task SerializeAsync(
7977
Utf8JsonWriter writer,
80-
#if EXPERIMENTAL_SERIALIZER
8178
ObjectSerializer serializer,
82-
#endif
8379
JsonSerializerOptions options,
8480
bool async,
8581
CancellationToken cancellationToken)
@@ -93,9 +89,7 @@ internal async Task SerializeAsync(
9389
{
9490
await action.SerializeAsync(
9591
writer,
96-
#if EXPERIMENTAL_SERIALIZER
9792
serializer,
98-
#endif
9993
options,
10094
async,
10195
cancellationToken)

sdk/search/Azure.Search.Documents/src/Models/SearchResults{T}.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
using System.Threading.Tasks;
1212
using Azure.Core;
1313
using Azure.Core.Pipeline;
14-
#if EXPERIMENTAL_SERIALIZER
1514
using Azure.Core.Serialization;
16-
#endif
1715

1816
#pragma warning disable SA1402 // File may only contain a single type
1917

@@ -167,9 +165,7 @@ await _pagingClient.SearchAsync<T>(
167165
/// <returns>Deserialized SearchResults.</returns>
168166
internal static async Task<SearchResults<T>> DeserializeAsync(
169167
Stream json,
170-
#if EXPERIMENTAL_SERIALIZER
171168
ObjectSerializer serializer,
172-
#endif
173169
bool async,
174170
CancellationToken cancellationToken)
175171
#pragma warning restore CS1572
@@ -240,9 +236,7 @@ await JsonDocument.ParseAsync(json, cancellationToken: cancellationToken).Config
240236
{
241237
SearchResult<T> result = await SearchResult<T>.DeserializeAsync(
242238
element,
243-
#if EXPERIMENTAL_SERIALIZER
244239
serializer,
245-
#endif
246240
defaultSerializerOptions,
247241
async,
248242
cancellationToken)

sdk/search/Azure.Search.Documents/src/Models/SearchResult{T}.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Azure.Core;
11-
#if EXPERIMENTAL_SERIALIZER
1211
using Azure.Core.Serialization;
13-
#endif
1412

1513
#pragma warning disable SA1402 // File may only contain a single type
1614

@@ -70,9 +68,7 @@ internal SearchResult() { }
7068
/// <returns>Deserialized SearchResults.</returns>
7169
internal static async Task<SearchResult<T>> DeserializeAsync(
7270
JsonElement element,
73-
#if EXPERIMENTAL_SERIALIZER
7471
ObjectSerializer serializer,
75-
#endif
7672
JsonSerializerOptions options,
7773
bool async,
7874
CancellationToken cancellationToken)
@@ -104,7 +100,6 @@ internal static async Task<SearchResult<T>> DeserializeAsync(
104100
}
105101

106102
// Deserialize the model
107-
#if EXPERIMENTAL_SERIALIZER
108103
if (serializer != null)
109104
{
110105
using Stream stream = element.ToStream();
@@ -115,7 +110,6 @@ internal static async Task<SearchResult<T>> DeserializeAsync(
115110
}
116111
else
117112
{
118-
#endif
119113
T document;
120114
if (async)
121115
{
@@ -127,9 +121,7 @@ internal static async Task<SearchResult<T>> DeserializeAsync(
127121
document = JsonSerializer.Deserialize<T>(element.GetRawText(), options);
128122
}
129123
result.Document = document;
130-
#if EXPERIMENTAL_SERIALIZER
131124
}
132-
#endif
133125

134126
return result;
135127
}

0 commit comments

Comments
 (0)