Skip to content

Commit b553218

Browse files
dev: added .editorconfig (#288)
1 parent 0abf57f commit b553218

File tree

84 files changed

+968
-2352
lines changed

Some content is hidden

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

84 files changed

+968
-2352
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[*.cs]
4+
5+
csharp_style_expression_bodied_methods = true:suggestion

examples/src/BasicExample/Program.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ internal class CmdOptions
2222

2323
internal static class Program
2424
{
25-
private static ServiceProvider GetServiceProvider()
26-
{
27-
return new ServiceCollection()
28-
.AddLogging(configure => configure.AddConsole().SetMinimumLevel(LogLevel.Information))
29-
.BuildServiceProvider();
30-
}
25+
private static ServiceProvider GetServiceProvider() => new ServiceCollection()
26+
.AddLogging(configure => configure.AddConsole().SetMinimumLevel(LogLevel.Information))
27+
.BuildServiceProvider();
3128

3229
private static async Task Run(CmdOptions cmdOptions)
3330
{

examples/src/Common/AuthUtils.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,10 @@ public static async Task<ICredentialsProvider> MakeCredentialsFromEnv(
5252
throw new InvalidOperationException("Failed to parse credentials from environmet, no valid options found.");
5353
}
5454

55-
public static X509Certificate GetCustomServerCertificate()
56-
{
57-
return YcCerts.GetDefaultServerCertificate();
58-
}
55+
public static X509Certificate GetCustomServerCertificate() => YcCerts.GetDefaultServerCertificate();
5956

60-
private static bool IsTrueValue(string value)
61-
{
62-
return
63-
value == "1" ||
64-
value.ToLower() == "yes" ||
65-
value.ToLower() == "true";
66-
}
57+
private static bool IsTrueValue(string value) =>
58+
value == "1" ||
59+
value.ToLower() == "yes" ||
60+
value.ToLower() == "true";
6761
}

examples/src/Common/DataUtils.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,27 @@ namespace Ydb.Sdk.Examples;
77

88
public record Series(ulong SeriesId, string Title, DateTime ReleaseDate, string Info)
99
{
10-
public static Series FromRow(Value.ResultSet.Row row)
11-
{
12-
return new Series(
10+
public static Series FromRow(Value.ResultSet.Row row) =>
11+
new(
1312
SeriesId: (ulong)row["series_id"].GetOptionalUint64()!,
1413
Title: (string)row["title"]!,
1514
ReleaseDate: (DateTime)row["release_date"].GetOptionalDate()!,
1615
Info: (string)row["series_info"]!
1716
);
18-
}
1917
}
2018

2119
public record Season(ulong SeriesId, ulong SeasonId, string Title, DateTime FirstAired, DateTime LastAired);
2220

2321
public record Episode(ulong SeriesId, ulong SeasonId, ulong EpisodeId, string Title, DateTime AirDate)
2422
{
25-
public static Episode FromRow(Value.ResultSet.Row row)
26-
{
27-
return new Episode(
23+
public static Episode FromRow(Value.ResultSet.Row row) =>
24+
new(
2825
SeriesId: (ulong)row["series_id"].GetOptionalUint64()!,
2926
SeasonId: (ulong)row["season_id"].GetOptionalUint64()!,
3027
EpisodeId: (ulong)row["episode_id"].GetOptionalUint64()!,
3128
Title: (string)row["title"]!,
3229
AirDate: (DateTime)row["air_date"].GetOptionalDate()!
3330
);
34-
}
3531
}
3632

3733
public static class DataUtils

examples/src/Common/TableExampleBase.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,5 @@ protected TableExampleBase(TableClient client, string database, string path)
1313
BasePath = string.Join('/', database, path);
1414
}
1515

16-
protected string FullTablePath(string table)
17-
{
18-
return string.Join('/', BasePath, table);
19-
}
16+
protected string FullTablePath(string table) => string.Join('/', BasePath, table);
2017
}

examples/src/DapperExample/Program.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,5 @@ internal class User
2929
public string Name { get; init; } = null!;
3030
public string Email { get; init; } = null!;
3131

32-
public override string ToString()
33-
{
34-
return $"Id: {Id}, Name: {Name}, Email: {Email}";
35-
}
32+
public override string ToString() => $"Id: {Id}, Name: {Name}, Email: {Email}";
3633
}

examples/src/QueryExample/Program.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ internal class CmdOptions
2424

2525
internal static class Program
2626
{
27-
private static ServiceProvider GetServiceProvider()
28-
{
29-
return new ServiceCollection()
27+
private static ServiceProvider GetServiceProvider() =>
28+
new ServiceCollection()
3029
.AddLogging(configure => configure.AddConsole().SetMinimumLevel(LogLevel.Information))
3130
.BuildServiceProvider();
32-
}
3331

3432
private static async Task Run(CmdOptions cmdOptions)
3533
{

examples/src/QueryExample/QueryExample.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@ await Client.Exec(
180180
}
181181

182182

183-
private async Task InteractiveTx()
184-
{
185-
await Client.DoTx(async tx =>
183+
private Task InteractiveTx() =>
184+
Client.DoTx(async tx =>
186185
{
187186
var query1 = @$"
188187
PRAGMA TablePathPrefix('{BasePath}');
@@ -217,7 +216,6 @@ UPSERT INTO seasons (series_id, season_id, first_aired) VALUES
217216
await tx.Exec(query2, parameters2);
218217
}
219218
);
220-
}
221219

222220
private async Task StreamSelect()
223221
{

slo/src/Internal/ConfigBinders.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ public class CreateConfigBinder(
1313
Option<int> writeTimeoutOption)
1414
: BinderBase<CreateConfig>
1515
{
16-
protected override CreateConfig GetBoundValue(BindingContext bindingContext)
17-
{
18-
return new CreateConfig(
16+
protected override CreateConfig GetBoundValue(BindingContext bindingContext) =>
17+
new(
1918
bindingContext.ParseResult.GetValueForArgument(endpointArgument),
2019
bindingContext.ParseResult.GetValueForArgument(dbArgument),
2120
bindingContext.ParseResult.GetValueForOption(resourceYdbPath)!,
@@ -24,7 +23,6 @@ protected override CreateConfig GetBoundValue(BindingContext bindingContext)
2423
bindingContext.ParseResult.GetValueForOption(initialDataCountOption),
2524
bindingContext.ParseResult.GetValueForOption(writeTimeoutOption)
2625
);
27-
}
2826
}
2927

3028
internal class RunConfigBinder(
@@ -40,9 +38,8 @@ internal class RunConfigBinder(
4038
Option<int> timeOption)
4139
: BinderBase<RunConfig>
4240
{
43-
protected override RunConfig GetBoundValue(BindingContext bindingContext)
44-
{
45-
return new RunConfig(
41+
protected override RunConfig GetBoundValue(BindingContext bindingContext) =>
42+
new(
4643
bindingContext.ParseResult.GetValueForArgument(endpointArgument),
4744
bindingContext.ParseResult.GetValueForArgument(dbArgument),
4845
bindingContext.ParseResult.GetValueForOption(resourceYdbPath)!,
@@ -54,5 +51,4 @@ protected override RunConfig GetBoundValue(BindingContext bindingContext)
5451
bindingContext.ParseResult.GetValueForOption(writeTimeoutOption),
5552
bindingContext.ParseResult.GetValueForOption(timeOption)
5653
);
57-
}
5854
}

slo/src/TableService/SloTableContext.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ protected override async Task Create(TableClient client, string createTableSql,
7777
response.Status.IsSuccess ? response.Result.ResultSets[0].Rows[0][0].GetOptionalInt32() : null);
7878
}
7979

80-
protected override async Task<TableClient> CreateClient(Config config)
81-
{
82-
return new TableClient(await Driver.CreateInitialized(new DriverConfig(config.Endpoint, config.Db),
83-
ISloContext.Factory));
84-
}
80+
protected override async Task<TableClient> CreateClient(Config config) => new(
81+
await Driver.CreateInitialized(new DriverConfig(config.Endpoint, config.Db), ISloContext.Factory)
82+
);
8583
}

0 commit comments

Comments
 (0)