Skip to content

Commit a08ccfc

Browse files
author
Stuart Cam
authored
Addition of [Obsolete(...)] attributes to 5.x (#3023)
Mark code as Obsolete as warning for 5.x users who are considering upgrade to 6.x
1 parent b570c0a commit a08ccfc

File tree

67 files changed

+293
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+293
-122
lines changed

src/Nest/Aggregations/Bucket/Histogram/HistogramAggregation.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ public class HistogramAggregation : BucketAggregationBase, IHistogramAggregation
4747
public int? MinimumDocumentCount { get; set; }
4848
public HistogramOrder Order { get; set; }
4949
public ExtendedBounds<double> ExtendedBounds { get; set; }
50+
51+
[Obsolete("Removed in Elasticsearch 2.0. Will be removed in the next major version of NEST")]
5052
public long? PreOffset { get; set; }
53+
54+
[Obsolete("Removed in Elasticsearch 2.0. Will be removed in the next major version of NEST")]
5155
public long? PostOffset { get; set; }
5256
public double? Offset { get; set; }
5357
public double? Missing { get; set; }
@@ -75,10 +79,12 @@ public class HistogramAggregationDescriptor<T>
7579

7680
ExtendedBounds<double> IHistogramAggregation.ExtendedBounds { get; set; }
7781

82+
[Obsolete("Removed in Elasticsearch 2.0. Will be removed in the next major version of NEST")]
7883
long? IHistogramAggregation.PreOffset { get; set; }
79-
84+
85+
[Obsolete("Removed in Elasticsearch 2.0. Will be removed in the next major version of NEST")]
8086
long? IHistogramAggregation.PostOffset { get; set; }
81-
87+
8288
double? IHistogramAggregation.Offset { get; set; }
8389

8490
double? IHistogramAggregation.Missing { get; set; }
@@ -113,7 +119,7 @@ public HistogramAggregationDescriptor<T> ExtendedBounds(double min, double max)
113119

114120
[Obsolete("Removed in Elasticsearch 2.0. Will be removed in the next major version of NEST")]
115121
public HistogramAggregationDescriptor<T> PostOffset(long postOffset) => this;
116-
122+
117123
public HistogramAggregationDescriptor<T> Offset(double offset) => Assign(a => a.Offset = offset);
118124

119125
public HistogramAggregationDescriptor<T> Missing(double missing) => Assign(a => a.Missing = missing);

src/Nest/Aggregations/Bucket/SignificantTerms/SignificantTermsAggregation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ public class SignificantTermsAggregationDescriptor<T>
201201

202202
TermsAggregationExecutionHint? ISignificantTermsAggregation.ExecutionHint { get; set; }
203203

204-
[Obsolete("Deprecated and will be fixed in 6.0. Use IncludeTerms")]
204+
[Obsolete("Deprecated, will be fixed in 6.0. Use IncludeTerms")]
205205
IDictionary<string, string> ISignificantTermsAggregation.Include { get; set; }
206206

207207
SignificantTermsIncludeExclude ISignificantTermsAggregation.IncludeTerms { get; set; }
208208

209-
[Obsolete("Deprecated and will be fixed in 6.0. Use ExcludeTerms")]
209+
[Obsolete("Deprecated, will be fixed in 6.0. Use ExcludeTerms")]
210210
IDictionary<string, string> ISignificantTermsAggregation.Exclude { get; set; }
211211

212212
SignificantTermsIncludeExclude ISignificantTermsAggregation.ExcludeTerms { get; set; }

src/Nest/Aggregations/Bucket/Terms/TermsAggregation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ public TermsAggregationDescriptor<T> Order(TermsOrder order) => Assign(a =>
124124
a.Order.Add(order);
125125
});
126126

127+
[Obsolete("Removed in NEST 6.x, use Order()")]
127128
public TermsAggregationDescriptor<T> OrderAscending(string key) => Assign(a =>
128129
{
129130
a.Order = a.Order ?? new List<TermsOrder>();
130131
a.Order.Add(new TermsOrder { Key = key, Order = SortOrder.Ascending });
131132
});
132133

134+
[Obsolete("Removed in NEST 6.x, use Order()")]
133135
public TermsAggregationDescriptor<T> OrderDescending(string key) => Assign(a =>
134136
{
135137
a.Order = a.Order ?? new List<TermsOrder>();

src/Nest/Aggregations/Metric/TopHits/TopHitsAggregation.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public interface ITopHitsAggregation : IMetricAggregation
3030
[JsonConverter(typeof(ReadAsTypeJsonConverter<ScriptFields>))]
3131
IScriptFields ScriptFields { get; set; }
3232

33+
[Obsolete("Removed in NEST 6.x")]
3334
[JsonProperty("fielddata_fields")]
3435
Fields FielddataFields { get; set; }
3536

@@ -52,6 +53,8 @@ public class TopHitsAggregation : MetricAggregationBase, ITopHitsAggregation
5253
public IHighlight Highlight { get; set; }
5354
public bool? Explain { get; set; }
5455
public IScriptFields ScriptFields { get; set; }
56+
57+
[Obsolete("Removed in NEST 6.x")]
5558
public Fields FielddataFields { get; set; }
5659
public Fields StoredFields { get; set; }
5760
public bool? Version { get; set; }
@@ -83,6 +86,7 @@ public class TopHitsAggregationDescriptor<T>
8386

8487
IScriptFields ITopHitsAggregation.ScriptFields { get; set; }
8588

89+
[Obsolete("Removed in NEST 6.x")]
8690
Fields ITopHitsAggregation.FielddataFields { get; set; }
8791

8892
Fields ITopHitsAggregation.StoredFields { get; set; }

src/Nest/Analysis/TokenFilters/HunspellTokenFilter.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
using Newtonsoft.Json;
1+
using System;
2+
using Newtonsoft.Json;
23

34
namespace Nest
45
{
56
/// <summary>
6-
/// Basic support for hunspell stemming.
7+
/// Basic support for hunspell stemming.
78
///<para> Hunspell dictionaries will be picked up from a dedicated hunspell directory on the filesystem.</para>
89
/// </summary>
910
public interface IHunspellTokenFilter : ITokenFilter
@@ -12,6 +13,7 @@ public interface IHunspellTokenFilter : ITokenFilter
1213
/// If true, dictionary matching will be case insensitive.
1314
/// </summary>
1415
[JsonProperty("ignore_case")]
16+
[Obsolete("Scheduled to be removed in 6.x - consider using a lowercase token filter before a hunspell token filter.")]
1517
bool? IgnoreCase { get; set; }
1618

1719
/// <summary>
@@ -21,7 +23,7 @@ public interface IHunspellTokenFilter : ITokenFilter
2123
string Locale { get; set; }
2224

2325
/// <summary>
24-
/// The name of a dictionary.The path to your hunspell dictionaries should be configured via
26+
/// The name of a dictionary.The path to your hunspell dictionaries should be configured via
2527
/// `indices.analysis.hunspell.dictionary.location` before.
2628
/// </summary>
2729
[JsonProperty("dictionary")]
@@ -44,9 +46,10 @@ public interface IHunspellTokenFilter : ITokenFilter
4446
/// <inheritdoc/>
4547
public class HunspellTokenFilter : TokenFilterBase, IHunspellTokenFilter
4648
{
47-
public HunspellTokenFilter() : base("hunspell") { }
49+
public HunspellTokenFilter() : base("hunspell") { }
4850

4951
/// <inheritdoc/>
52+
[Obsolete("Scheduled to be removed in 6.x - consider using a lowercase token filter before a hunspell token filter.")]
5053
public bool? IgnoreCase { get; set; }
5154

5255
/// <inheritdoc/>
@@ -65,13 +68,15 @@ public HunspellTokenFilter() : base("hunspell") { }
6568
}
6669

6770
///<inheritdoc/>
68-
public class HunspellTokenFilterDescriptor
71+
public class HunspellTokenFilterDescriptor
6972
: TokenFilterDescriptorBase<HunspellTokenFilterDescriptor, IHunspellTokenFilter>, IHunspellTokenFilter
7073
{
7174
protected override string Type => "hunspell";
7275

7376
bool? IHunspellTokenFilter.LongestOnly { get; set; }
7477
bool? IHunspellTokenFilter.Dedup { get; set; }
78+
79+
[Obsolete("Scheduled to be removed in 6.x - consider using a lowercase token filter before a hunspell token filter.")]
7580
bool? IHunspellTokenFilter.IgnoreCase { get; set; }
7681
string IHunspellTokenFilter.Locale { get; set; }
7782
string IHunspellTokenFilter.Dictionary { get; set; }
@@ -83,6 +88,7 @@ public class HunspellTokenFilterDescriptor
8388
public HunspellTokenFilterDescriptor Dedup(bool? dedup = true) => Assign(a => a.Dedup = dedup);
8489

8590
///<inheritdoc/>
91+
[Obsolete("Scheduled to be removed in 6.x - consider using a lowercase token filter before a hunspell token filter.")]
8692
public HunspellTokenFilterDescriptor IgnoreCase(bool? ignoreCase = true) => Assign(a => a.IgnoreCase = ignoreCase);
8793

8894
///<inheritdoc/>
@@ -93,4 +99,4 @@ public class HunspellTokenFilterDescriptor
9399

94100
}
95101

96-
}
102+
}

src/Nest/Cluster/NodesStats/NodeStats.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using Newtonsoft.Json;
34

45
namespace Nest
@@ -391,6 +392,7 @@ public class DataPathStats
391392
[JsonProperty("type")]
392393
public string Type { get; internal set; }
393394
[JsonProperty("spins")]
395+
[Obsolete("Scheduled to be removed in 6.0")]
394396
public bool? Spins { get; internal set; }
395397
[JsonProperty("total")]
396398
public string Total { get; internal set; }

src/Nest/CommonAbstractions/ConnectionSettings/ClrTypeMapping.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ namespace Nest
77
{
88
public interface IClrTypeMapping<T> where T : class
99
{
10-
Type Type { get; }
10+
Type Type { get; }
1111

1212
/// <summary>
13-
/// When specified dictates the default Elasticsearch index name for <typeparamref name="T"/>
13+
/// When specified dictates the default Elasticsearch index name for <typeparamref name="T"/>
1414
/// </summary>
1515
string IndexName { get; set; }
1616

@@ -20,10 +20,10 @@ public interface IClrTypeMapping<T> where T : class
2020
string TypeName { get; set; }
2121

2222
/// <summary>
23-
/// Allows you to set a default Id property on <typeparamref name="T" /> that NEST will evaluate
23+
/// Allows you to set a default Id property on <typeparamref name="T" /> that NEST will evaluate
2424
/// </summary>
2525
Expression<Func<T, object>> IdProperty { get; set; }
26-
26+
2727
/// <summary>
2828
/// When specified allows you to ignore or rename certain properties of clr type <typeparamref name="T" />
2929
/// </summary>
@@ -35,7 +35,7 @@ public class ClrTypeMapping<T> : IClrTypeMapping<T> where T : class
3535
public Type Type { get; } = typeof (T);
3636

3737
/// <summary>
38-
/// When specified dictates the default Elasticsearch index name for <typeparamref name="T"/>
38+
/// When specified dictates the default Elasticsearch index name for <typeparamref name="T"/>
3939
/// </summary>
4040
public string IndexName { get; set; }
4141

@@ -45,7 +45,7 @@ public class ClrTypeMapping<T> : IClrTypeMapping<T> where T : class
4545
public string TypeName { get; set; }
4646

4747
/// <summary>
48-
/// Allows you to set a default Id property on <typeparamref name="T" /> that NEST will evaluate
48+
/// Allows you to set a default Id property on <typeparamref name="T" /> that NEST will evaluate
4949
/// </summary>
5050
public Expression<Func<T, object>> IdProperty { get; set; }
5151

@@ -62,7 +62,7 @@ public class ClrTypeMappingDescriptor<T> : DescriptorBase<ClrTypeMappingDescript
6262
IList<IClrTypePropertyMapping<T>> IClrTypeMapping<T>.Properties { get; set; } = new List<IClrTypePropertyMapping<T>>();
6363

6464
/// <summary>
65-
/// When specified dictates the default Elasticsearch index name for <typeparamref name="T"/>
65+
/// When specified dictates the default Elasticsearch index name for <typeparamref name="T"/>
6666
/// </summary>
6767
public ClrTypeMappingDescriptor<T> IndexName(string indexName) => Assign(a => a.IndexName = indexName);
6868

@@ -72,20 +72,20 @@ public class ClrTypeMappingDescriptor<T> : DescriptorBase<ClrTypeMappingDescript
7272
public ClrTypeMappingDescriptor<T> TypeName(string typeName) => Assign(a => a.TypeName = typeName);
7373

7474
/// <summary>
75-
/// Allows you to set a default Id property on <typeparamref name="T" /> that NEST will evaluate
75+
/// Allows you to set a default Id property on <typeparamref name="T" /> that NEST will evaluate
7676
/// </summary>
7777
public ClrTypeMappingDescriptor<T> IdProperty(Expression<Func<T, object>> property) => Assign(a => a.IdProperty = property);
7878

7979
/// <summary>
8080
/// When specified allows you to ignore <param name="property"></param> on clr type <typeparamref name="T" />
8181
/// </summary>
82-
public ClrTypeMappingDescriptor<T> Ignore(Expression<Func<T, object>> property) =>
82+
public ClrTypeMappingDescriptor<T> Ignore(Expression<Func<T, object>> property) =>
8383
Assign(a => a.Properties.Add(new IgnorePropertyMapping<T>(property)));
8484

8585
/// <summary>
8686
/// When specified allows you to rename <param name="property"></param> on clr type <typeparamref name="T" />
8787
/// </summary>
88-
public ClrTypeMappingDescriptor<T> Rename(Expression<Func<T, object>> property, string newName) =>
88+
public ClrTypeMappingDescriptor<T> Rename(Expression<Func<T, object>> property, string newName) =>
8989
Assign(a => a.Properties.Add(new RenamePropertyMapping<T>(property, newName)));
9090

9191
}

src/Nest/CommonAbstractions/ConnectionSettings/ConnectionSettingsBase.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ IElasticsearchSerializer IConnectionSettingsValues.StatefulSerializer(JsonConver
116116
/// <summary>
117117
/// Pluralize type names when inferring from POCO type names.
118118
/// <para></para>
119-
/// This calls <see cref="DefaultTypeNameInferrer"/> with an implementation that will pluralize type names.
119+
/// This calls <see cref="DefaultTypeNameInferrer"/> with an implementation that will pluralize type names.
120120
/// This used to be the default prior to Nest 0.90
121121
/// </summary>
122122
public TConnectionSettings PluralizeTypeNames()
@@ -146,7 +146,7 @@ private string LowerCaseAndPluralizeTypeNameInferrer(Type type)
146146
/// <summary>
147147
/// Specify how field names are inferred from POCO property names.
148148
/// <para></para>
149-
/// By default, NEST camel cases property names
149+
/// By default, NEST camel cases property names
150150
/// e.g. EmailAddress POCO property => "emailAddress" Elasticsearch document field name
151151
/// </summary>
152152
public TConnectionSettings DefaultFieldNameInferrer(Func<string, string> fieldNameInferrer)
@@ -156,7 +156,7 @@ public TConnectionSettings DefaultFieldNameInferrer(Func<string, string> fieldNa
156156
}
157157

158158
/// <summary>
159-
/// Specify how type names are inferred from POCO types.
159+
/// Specify how type names are inferred from POCO types.
160160
/// By default, type names are inferred by calling <see cref="string.ToLowerInvariant"/>
161161
/// on the type's name.
162162
/// </summary>
@@ -168,9 +168,10 @@ public TConnectionSettings DefaultTypeNameInferrer(Func<Type, string> typeNameIn
168168
}
169169

170170
/// <summary>
171-
/// Specify the default index names for a given POCO type.
171+
/// Specify the default index names for a given POCO type.
172172
/// Takes precedence over the global <see cref="DefaultIndex"/>
173173
/// </summary>
174+
/// <remarks>Removed in 6.x.</remarks>
174175
public TConnectionSettings MapDefaultTypeIndices(Action<FluentDictionary<Type, string>> mappingSelector)
175176
{
176177
mappingSelector.ThrowIfNull(nameof(mappingSelector));
@@ -179,9 +180,10 @@ public TConnectionSettings MapDefaultTypeIndices(Action<FluentDictionary<Type, s
179180
}
180181

181182
/// <summary>
182-
/// Specify the default type names for a given POCO type.
183+
/// Specify the default type names for a given POCO type.
183184
/// Takes precedence over the global <see cref="DefaultTypeNameInferrer"/>
184185
/// </summary>
186+
/// <remarks>Removed in 6.x.</remarks>
185187
public TConnectionSettings MapDefaultTypeNames(Action<FluentDictionary<Type, string>> mappingSelector)
186188
{
187189
mappingSelector.ThrowIfNull(nameof(mappingSelector));
@@ -190,12 +192,13 @@ public TConnectionSettings MapDefaultTypeNames(Action<FluentDictionary<Type, str
190192
}
191193

192194
/// <summary>
193-
/// Specify which property on a given POCO should be used to infer the id of the document when
195+
/// Specify which property on a given POCO should be used to infer the id of the document when
194196
/// indexed in Elasticsearch.
195197
/// </summary>
196198
/// <typeparam name="TDocument">The type of the document.</typeparam>
197199
/// <param name="objectPath">The object path.</param>
198200
/// <returns></returns>
201+
/// <remarks>Removed in 6.x.</remarks>
199202
public TConnectionSettings MapIdPropertyFor<TDocument>(Expression<Func<TDocument, object>> objectPath)
200203
{
201204
objectPath.ThrowIfNull(nameof(objectPath));
@@ -222,6 +225,7 @@ public TConnectionSettings MapIdPropertyFor<TDocument>(Expression<Func<TDocument
222225
/// <typeparam name="TDocument">The type of the document.</typeparam>
223226
/// <param name="propertiesSelector">The properties selector.</param>
224227
/// <returns></returns>
228+
/// <remarks>Removed in 6.x.</remarks>
225229
public TConnectionSettings MapPropertiesFor<TDocument>(Action<PropertyMappingDescriptor<TDocument>> propertiesSelector)
226230
where TDocument : class
227231
{
@@ -264,7 +268,7 @@ private void ApplyPropertyMappings<TDocument>(IList<IClrTypePropertyMapping<TDoc
264268
}
265269

266270
/// <summary>
267-
/// Specify how the mapping is inferred for a given POCO type.
271+
/// Specify how the mapping is inferred for a given POCO type.
268272
/// Can be used to infer the index, type, id property and properties for the POCO.
269273
/// </summary>
270274
/// <typeparam name="TDocument">The type of the document.</typeparam>

src/Nest/CommonOptions/Scripting/FileScript.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
using Newtonsoft.Json;
1+
using System;
2+
using Newtonsoft.Json;
23

34
namespace Nest
45
{
6+
/// <remarks>Removed in 6.x</remarks>
57
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
68
public interface IFileScript : IScript
79
{
810
[JsonProperty("file")]
911
string File { get; set; }
1012
}
1113

14+
/// <remarks>Removed in 6.x</remarks>
1215
public class FileScript : ScriptBase, IFileScript
1316
{
1417
public FileScript(string file)
@@ -19,6 +22,7 @@ public FileScript(string file)
1922
public string File { get; set; }
2023
}
2124

25+
/// <remarks>Removed in 6.x</remarks>
2226
public class FileScriptDescriptor
2327
: ScriptDescriptorBase<FileScriptDescriptor, IFileScript>, IFileScript
2428
{

src/Nest/CommonOptions/Scripting/ScriptBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public TDescriptor Params(Func<FluentDictionary<string, object>, FluentDictionar
4242

4343
public class ScriptDescriptor : DescriptorBase<ScriptDescriptor, IDescriptor>
4444
{
45+
[Obsolete("Removed in NEST 6.x.")]
4546
public FileScriptDescriptor File(string file) => new FileScriptDescriptor(file);
4647

4748
public IndexedScriptDescriptor Indexed(string id) => new IndexedScriptDescriptor(id);

0 commit comments

Comments
 (0)