Skip to content

Commit b521bee

Browse files
committed
Fix warnings related to usage of deprecated string type
1 parent 4892127 commit b521bee

File tree

10 files changed

+24
-4
lines changed

10 files changed

+24
-4
lines changed

src/Nest/Mapping/Types/Core/String/StringAttribute.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
namespace Nest
1+
using System;
2+
3+
namespace Nest
24
{
5+
[Obsolete("Only valid for indices created before Elasticsearch 5.0 and will be removed in the next major version. For newly created indices, use Text or Keyword attribute instead.")]
36
public class StringAttribute : ElasticsearchDocValuesPropertyAttributeBase, IStringProperty
47
{
58
IStringProperty Self => this;

src/Nest/Mapping/Types/PropertyJsonConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
3434
case "keyword":
3535
return jObject.ToObject<KeywordProperty>();
3636
case "string":
37+
#pragma warning disable 618
3738
return jObject.ToObject<StringProperty>();
39+
#pragma warning restore 618
3840
case "float":
3941
case "double":
4042
case "byte":

src/Nest/Mapping/Visitor/IMappingVisitor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ public interface IMappingVisitor
66
{
77
int Depth { get; set; }
88
void Visit(TypeMapping mapping);
9+
#pragma warning disable 618
910
void Visit(StringProperty property);
11+
#pragma warning restore 618
1012
void Visit(TextProperty property);
1113
void Visit(KeywordProperty property);
1214
void Visit(DateProperty property);
@@ -30,8 +32,9 @@ public class NoopMappingVisitor : IMappingVisitor
3032

3133
public virtual void Visit(TypeMapping mapping) { }
3234

35+
#pragma warning disable 618
3336
public virtual void Visit(StringProperty property ) { }
34-
37+
#pragma warning restore 618
3538
public virtual void Visit(TextProperty property) { }
3639

3740
public virtual void Visit(KeywordProperty property) { }

src/Nest/Mapping/Visitor/IPropertyVisitor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ namespace Nest
44
{
55
public interface IPropertyVisitor
66
{
7+
#pragma warning disable 618
78
void Visit(IStringProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute);
9+
#pragma warning restore 618
810
void Visit(ITextProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute);
911
void Visit(IKeywordProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute);
1012
void Visit(INumberProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute);

src/Nest/Mapping/Visitor/MappingWalker.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ public void Accept(IProperties properties)
4848
this.Accept(k.Fields);
4949
break;
5050
case "string":
51+
#pragma warning disable 618
5152
var s = field as StringProperty;
53+
#pragma warning restore 618
5254
if (s == null) continue;
5355
this._visitor.Visit(s);
5456
this.Accept(s.Fields);

src/Nest/Mapping/Visitor/NoopPropertyVisitor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ public virtual void Visit(ITextProperty type, PropertyInfo propertyInfo, Elastic
6363
public virtual void Visit(IKeywordProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute)
6464
{
6565
}
66+
67+
#pragma warning disable 618
6668
public virtual void Visit(IStringProperty type, PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute)
6769
{
6870
}
71+
#pragma warning restore 618
6972

7073
public virtual IProperty Visit(PropertyInfo propertyInfo, ElasticsearchPropertyAttributeBase attribute) => null;
7174

src/Tests/Document/Multiple/UpdateByQuery/UpdateByQueryApiTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ protected override void IntegrationSetup(IElasticClient client, CallUniqueValues
2828
{
2929
foreach (var index in values.Values)
3030
{
31+
#pragma warning disable 618
3132
this.Client.CreateIndex(index, c => c
3233
.Mappings(m => m
3334
.Map<Test>(map => map
@@ -38,6 +39,7 @@ protected override void IntegrationSetup(IElasticClient client, CallUniqueValues
3839
)
3940
)
4041
);
42+
#pragma warning restore 618
4143
this.Client.Index(new Test { Text = "words words", Flag = "bar" }, i=>i.Index(index).Refresh());
4244
this.Client.Index(new Test { Text = "words words", Flag = "foo" }, i=>i.Index(index).Refresh());
4345
this.Client.Map<Test>(m => m

src/Tests/Document/Single/Index/IndexIngestAttachmentApiTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override void IntegrationSetup(IElasticClient client, CallUniqueValues
4242
.Mappings(m => m
4343
.Map<IngestedAttachment>(mm => mm
4444
.Properties(p => p
45-
.String(s => s
45+
.Text(s => s
4646
.Name(f => f.Content)
4747
)
4848
.Object<Nest.Attachment>(o => o

src/Tests/Indices/MappingManagement/GetMapping/GetMappingApiTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ public void CountsShouldContainKeyAndCountBe(string key, int count)
8282
this.Counts[key].Should().Be(count);
8383
}
8484

85+
#pragma warning disable 618
8586
public void Visit(StringProperty mapping)
8687
{
8788
Increment("string");
8889
}
89-
90+
#pragma warning restore 618
9091
public void Visit(DateProperty mapping)
9192
{
9293
Increment("date");

src/Tests/Mapping/Types/Core/String/StringMappingTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using Nest;
33

4+
#pragma warning disable 618
45
namespace Tests.Mapping.Types.Core.String
56
{
67
public class StringTest
@@ -133,3 +134,4 @@ public class StringMappingTests : TypeMappingTestBase<StringTest>
133134
);
134135
}
135136
}
137+
#pragma warning restore 618

0 commit comments

Comments
 (0)