Skip to content

Commit f07b8ea

Browse files
committed
added field resolving precedence documentation tests
1 parent 21606e5 commit f07b8ea

File tree

14 files changed

+270
-326
lines changed

14 files changed

+270
-326
lines changed

src/CodeGeneration/Nest.Litterateur/Documentation/CSharpDocumentationFile.cs

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

src/CodeGeneration/Nest.Litterateur/Documentation/DocumentationBlocks.cs

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

src/CodeGeneration/Nest.Litterateur/Nest.Litterateur.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@
3838
<Reference Include="System.Core" />
3939
</ItemGroup>
4040
<ItemGroup>
41-
<Compile Include="Documentation\DocumentationBlocks.cs" />
42-
<Compile Include="Documentation\CSharpDocumentationFile.cs" />
41+
<Compile Include="Documentation\Blocks\CodeBlock.cs" />
42+
<Compile Include="Documentation\Blocks\CombinedBlock.cs" />
43+
<Compile Include="Documentation\Blocks\IDocumentationBlock.cs" />
44+
<Compile Include="Documentation\Blocks\TextBlock.cs" />
45+
<Compile Include="Documentation\Files\CSharpDocumentationFile.cs" />
46+
<Compile Include="Documentation\Files\DocumentationFile.cs" />
47+
<Compile Include="Documentation\Files\RawDocumentationFile.cs" />
4348
<Compile Include="EnumerableExtensions.cs" />
49+
<Compile Include="Linker\Linker.cs" />
4450
<Compile Include="Walkers\CodeWithDocumentationWalker.cs" />
4551
<Compile Include="Program.cs" />
4652
<Compile Include="Properties\AssemblyInfo.cs" />

src/CodeGeneration/Nest.Litterateur/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using Nest.Litterateur.Documentation.Files;
56

67
namespace Nest.Litterateur
78
{
@@ -23,13 +24,11 @@ from f in Directory.GetFiles(TestFolder, $"*.{extension}", SearchOption.AllDirec
2324

2425
public static void Go()
2526
{
26-
var files = FindAll("cs").Concat(FindAll("asciidoc")).Concat(FindAll("png")).Concat(FindAll("gif"));
27+
var files = FindAll("doc.cs").Concat(FindAll("asciidoc")).Concat(FindAll("png")).Concat(FindAll("gif"));
2728
foreach (var file in files)
2829
file.SaveToDocumentationFolder();
2930

3031
}
31-
32-
3332
}
3433
}
3534
}

src/CodeGeneration/Nest.Litterateur/Walkers/CodeWithDocumentationWalker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Linq;
88
using System.Text;
99
using System.Text.RegularExpressions;
10+
using Nest.Litterateur.Documentation.Blocks;
1011

1112
namespace Nest.Litterateur.Walkers
1213
{

src/CodeGeneration/Nest.Litterateur/Walkers/DocumentationFileWalker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Collections.Generic;
77
using System.Linq;
88
using System.Text;
9+
using Nest.Litterateur.Documentation.Blocks;
910

1011
namespace Nest.Litterateur.Walkers
1112
{

src/Nest/CommonAbstractions/SerializationBehavior/ElasticContractResolver.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ private bool ApplyExactContractJsonAttribute(Type objectType, JsonContract contr
7171
contract.Converter = attribute.Converter;
7272
return true;
7373
}
74+
7475
private bool ApplyContractJsonAttribute(Type objectType, JsonContract contract)
7576
{
7677
foreach (var t in this.TypeWithInterfaces(objectType))
@@ -168,11 +169,16 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ
168169
var jsonIgnoreAttribute = member.GetCustomAttributes(typeof(JsonIgnoreAttribute), true);
169170
if (jsonIgnoreAttribute.HasAny())
170171
property.Ignored = true;
172+
173+
var propertyName = this.ConnectionSettings.Serializer?.CreatePropertyName(member);
174+
if (!propertyName.IsNullOrEmpty())
175+
property.PropertyName = propertyName;
171176
return property;
172177
}
173178

174179
if (!propertyMapping.Name.IsNullOrEmpty())
175180
property.PropertyName = propertyMapping.Name;
181+
176182
property.Ignored = propertyMapping.Ignore;
177183

178184
return property;

src/Nest/CommonAbstractions/SerializationBehavior/JsonNetSerializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal JsonNetSerializer(IConnectionSettingsValues settings, JsonConverter sta
4646
};
4747
}
4848

49-
public void Serialize(object data, Stream writableStream, SerializationFormatting formatting = SerializationFormatting.Indented)
49+
public virtual void Serialize(object data, Stream writableStream, SerializationFormatting formatting = SerializationFormatting.Indented)
5050
{
5151
var serializer = _defaultSerializers[formatting];
5252
using (var writer = new StreamWriter(writableStream, ExpectedEncoding, 8096, leaveOpen: true))
@@ -58,7 +58,7 @@ public void Serialize(object data, Stream writableStream, SerializationFormattin
5858
}
5959
}
6060

61-
public string CreatePropertyName(MemberInfo memberInfo)
61+
public virtual string CreatePropertyName(MemberInfo memberInfo)
6262
{
6363
var jsonProperty = memberInfo.GetCustomAttribute<JsonPropertyAttribute>(true);
6464
return jsonProperty?.PropertyName;
@@ -75,7 +75,7 @@ public virtual T Deserialize<T>(Stream stream)
7575
}
7676
}
7777

78-
public Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default(CancellationToken))
78+
public virtual Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default(CancellationToken))
7979
{
8080
//Json.NET does not support reading a stream asynchronously :(
8181
var result = this.Deserialize<T>(stream);

src/Nest/Document/Multiple/Bulk/BulkOperation/BulkOperationBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@ public abstract class BulkOperationDescriptorBase<TDescriptor, TInterface>
6767
/// Manually set the index, default to the default index or the fixed index set on the bulk operation
6868
/// </summary>
6969
public TDescriptor Index(IndexName index) => Assign(a => a.Index = index);
70+
public TDescriptor Index<T>() => Assign(a => a.Index = typeof(T));
7071

7172
/// <summary>
7273
/// Manualy set the type to get the object from, default to whatever
7374
/// T will be inferred to if not passed or the fixed type set on the parent bulk operation
7475
/// </summary>
7576
public TDescriptor Type(TypeName type) => Assign(a => a.Type = type);
77+
public TDescriptor Type<T>() => Assign(a => a.Type = typeof(T));
7678

7779
/// <summary>
7880
/// Manually set the id for the newly created object

0 commit comments

Comments
 (0)