Skip to content

Commit

Permalink
* implicit usings on tests and file scoped namespaces
Browse files Browse the repository at this point in the history
* added solution settings
* major cleanup on tests
  • Loading branch information
RagingKore committed Oct 21, 2023
1 parent fa00978 commit 33512f3
Show file tree
Hide file tree
Showing 291 changed files with 9,321 additions and 9,223 deletions.
15 changes: 8 additions & 7 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;</TargetFrameworks>
<Platform>x64</Platform>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Nullable>enable</Nullable>
<NullableContextOptions>enable</NullableContextOptions>
<ImplicitUsings>true</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>11</LangVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<DebugType Condition=" '$(Configuration)' == 'Debug' ">full</DebugType>
<DebugType Condition=" '$(Configuration)' == 'Release' ">pdbonly</DebugType>
<!-- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>-->
<!-- <DebugType Condition=" '$(Configuration)' == 'Debug' ">full</DebugType>-->
<!-- <DebugType Condition=" '$(Configuration)' == 'Release' ">pdbonly</DebugType>-->
<!-- <OutputPath>$(MSBuildThisFileDirectory)\bin\$(Configuration)\$(MSBuildProjectName)\</OutputPath>-->
<RootNamespace>EventStore.Client</RootNamespace>

<UseLinkBase>true</UseLinkBase>
<GrpcPackageVersion>2.49.0</GrpcPackageVersion>
<GrpcToolsPackageVersion>2.50.0</GrpcToolsPackageVersion>
<GrpcPackageVersion>2.49.0</GrpcPackageVersion>
<GrpcToolsPackageVersion>2.50.0</GrpcToolsPackageVersion>
</PropertyGroup>
</Project>
397 changes: 377 additions & 20 deletions EventStore.Client.sln.DotSettings

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<Nullable>enable</Nullable>
<NullableContextOptions>enable</NullableContextOptions>
<OutputType>Exe</OutputType>
<TargetFrameworks>net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>
</Project>
10 changes: 8 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"/>
<PropertyGroup>
<RootNamespace>EventStore.Client</RootNamespace>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<DebugType Condition=" '$(Configuration)' == 'Debug' ">full</DebugType>
<DebugType Condition=" '$(Configuration)' == 'Release' ">pdbonly</DebugType>
</PropertyGroup>
<PropertyGroup Condition="$(MSBuildProjectName) != 'EventStore.Client'">
<ESPackageIdSuffix>$(MSBuildProjectName.Remove(0,18))</ESPackageIdSuffix>
<ESProto>$(ESPackageIdSuffix.ToLower()).proto</ESProto>
Expand Down Expand Up @@ -31,7 +37,7 @@
<None Include="..\..\ouro.png" Pack="true" PackagePath="\"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="5.0.0.1">
<PackageReference Include="ConfigureAwaitChecker.Analyzer" Version="4.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -42,7 +48,7 @@
<PackageReference Include="MinVer" Version="3.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Compile Include="../EventStore.Client.Common/**/*.cs"/>
<Compile Include="../EventStore.Client.Common/**/*.cs" Link="Common\%(RecursiveDir)/%(FileName)%(Extension)"/>
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
Expand Down
3 changes: 1 addition & 2 deletions src/EventStore.Client.Common/AsyncStreamReaderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using Grpc.Core;

namespace EventStore.Client {
internal static class AsyncStreamReaderExtensions {
public static async IAsyncEnumerable<T> ReadAllAsync<T>(this IAsyncStreamReader<T> reader,
Expand Down
122 changes: 61 additions & 61 deletions src/EventStore.Client.Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
namespace EventStore.Client {
internal static class Constants {
public static class Exceptions {
public const string ExceptionKey = "exception";

public const string AccessDenied = "access-denied";
public const string InvalidTransaction = "invalid-transaction";
public const string StreamDeleted = "stream-deleted";
public const string WrongExpectedVersion = "wrong-expected-version";
public const string StreamNotFound = "stream-not-found";
public const string MaximumAppendSizeExceeded = "maximum-append-size-exceeded";
public const string MissingRequiredMetadataProperty = "missing-required-metadata-property";
public const string NotLeader = "not-leader";

public const string PersistentSubscriptionFailed = "persistent-subscription-failed";
public const string PersistentSubscriptionDoesNotExist = "persistent-subscription-does-not-exist";
public const string PersistentSubscriptionExists = "persistent-subscription-exists";
public const string MaximumSubscribersReached = "maximum-subscribers-reached";
public const string PersistentSubscriptionDropped = "persistent-subscription-dropped";

public const string UserNotFound = "user-not-found";
public const string UserConflict = "user-conflict";

public const string ScavengeNotFound = "scavenge-not-found";

public const string ExpectedVersion = "expected-version";
public const string ActualVersion = "actual-version";
public const string StreamName = "stream-name";
public const string GroupName = "group-name";
public const string Reason = "reason";
public const string MaximumAppendSize = "maximum-append-size";
public const string RequiredMetadataProperties = "required-metadata-properties";
public const string ScavengeId = "scavenge-id";
public const string LeaderEndpointHost = "leader-endpoint-host";
public const string LeaderEndpointPort = "leader-endpoint-port";

public const string LoginName = "login-name";
}

public static class Metadata {
public const string Type = "type";
public const string Created = "created";
public const string ContentType = "content-type";
public static readonly string[] RequiredMetadata = {Type, ContentType};

public static class ContentTypes {
public const string ApplicationJson = "application/json";
public const string ApplicationOctetStream = "application/octet-stream";
}
}

public static class Headers {
public const string Authorization = "authorization";
public const string BasicScheme = "Basic";
public const string BearerScheme = "Bearer";

public const string ConnectionName = "connection-name";
public const string RequiresLeader = "requires-leader";
}
}
}
namespace EventStore.Client;

internal static class Constants {
public static class Exceptions {
public const string ExceptionKey = "exception";

public const string AccessDenied = "access-denied";
public const string InvalidTransaction = "invalid-transaction";
public const string StreamDeleted = "stream-deleted";
public const string WrongExpectedVersion = "wrong-expected-version";
public const string StreamNotFound = "stream-not-found";
public const string MaximumAppendSizeExceeded = "maximum-append-size-exceeded";
public const string MissingRequiredMetadataProperty = "missing-required-metadata-property";
public const string NotLeader = "not-leader";

public const string PersistentSubscriptionFailed = "persistent-subscription-failed";
public const string PersistentSubscriptionDoesNotExist = "persistent-subscription-does-not-exist";
public const string PersistentSubscriptionExists = "persistent-subscription-exists";
public const string MaximumSubscribersReached = "maximum-subscribers-reached";
public const string PersistentSubscriptionDropped = "persistent-subscription-dropped";

public const string UserNotFound = "user-not-found";
public const string UserConflict = "user-conflict";

public const string ScavengeNotFound = "scavenge-not-found";

public const string ExpectedVersion = "expected-version";
public const string ActualVersion = "actual-version";
public const string StreamName = "stream-name";
public const string GroupName = "group-name";
public const string Reason = "reason";
public const string MaximumAppendSize = "maximum-append-size";
public const string RequiredMetadataProperties = "required-metadata-properties";
public const string ScavengeId = "scavenge-id";
public const string LeaderEndpointHost = "leader-endpoint-host";
public const string LeaderEndpointPort = "leader-endpoint-port";

public const string LoginName = "login-name";
}

public static class Metadata {
public const string Type = "type";
public const string Created = "created";
public const string ContentType = "content-type";
public static readonly string[] RequiredMetadata = {Type, ContentType};

public static class ContentTypes {
public const string ApplicationJson = "application/json";
public const string ApplicationOctetStream = "application/octet-stream";
}
}

public static class Headers {
public const string Authorization = "authorization";
public const string BasicScheme = "Basic";
public const string BearerScheme = "Bearer";

public const string ConnectionName = "connection-name";
public const string RequiresLeader = "requires-leader";
}
}
2 changes: 0 additions & 2 deletions src/EventStore.Client.Common/EpochExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace EventStore.Client {
internal static class EpochExtensions {
private static readonly DateTime UnixEpoch = DateTime.UnixEpoch;
Expand Down
2 changes: 0 additions & 2 deletions src/EventStore.Client.Common/EventStoreCallOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.Threading;
using Grpc.Core;
using Timeout_ = System.Threading.Timeout;

Expand Down
46 changes: 23 additions & 23 deletions src/EventStore.Client.Common/MetadataExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
using Grpc.Core;

namespace EventStore.Client {
internal static class MetadataExtensions {
public static bool TryGetValue(this Metadata metadata, string key, out string? value) {
value = default;
namespace EventStore.Client;

foreach (var entry in metadata) {
if (entry.Key != key) {
continue;
}
value = entry.Value;
return true;
}
internal static class MetadataExtensions {
public static bool TryGetValue(this Metadata metadata, string key, out string? value) {
value = default;

return false;
}
foreach (var entry in metadata) {
if (entry.Key != key) {
continue;
}
value = entry.Value;
return true;
}

public static StreamRevision GetStreamRevision(this Metadata metadata, string key)
=> metadata.TryGetValue(key, out var s) && ulong.TryParse(s, out var value)
? new StreamRevision(value)
: StreamRevision.None;
return false;
}

public static int GetIntValueOrDefault(this Metadata metadata, string key)
=> metadata.TryGetValue(key, out var s) && int.TryParse(s, out var value)
? value
: default;
}
}
public static StreamRevision GetStreamRevision(this Metadata metadata, string key)
=> metadata.TryGetValue(key, out var s) && ulong.TryParse(s, out var value)
? new StreamRevision(value)
: StreamRevision.None;

public static int GetIntValueOrDefault(this Metadata metadata, string key)
=> metadata.TryGetValue(key, out var s) && int.TryParse(s, out var value)
? value
: default;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace EventStore.Client {
public partial class EventStoreProjectionManagementClient {
static readonly JsonSerializerOptions DefaultJsonSerializerOptions = new JsonSerializerOptions();

/// <summary>
/// Gets the result of a projection as an untyped document.
/// </summary>
Expand All @@ -27,7 +29,7 @@ public async Task<JsonDocument> GetResultAsync(string name, string? partition =
await using var stream = new MemoryStream();
await using var writer = new Utf8JsonWriter(stream);
var serializer = new ValueSerializer();
serializer.Write(writer, value, new JsonSerializerOptions());
serializer.Write(writer, value, DefaultJsonSerializerOptions);
await writer.FlushAsync(cancellationToken).ConfigureAwait(false);
stream.Position = 0;

Expand All @@ -54,7 +56,7 @@ public async Task<T> GetResultAsync<T>(string name, string? partition = null,
await using var stream = new MemoryStream();
await using var writer = new Utf8JsonWriter(stream);
var serializer = new ValueSerializer();
serializer.Write(writer, value, new JsonSerializerOptions());
serializer.Write(writer, value, DefaultJsonSerializerOptions);
await writer.FlushAsync(cancellationToken).ConfigureAwait(false);
stream.Position = 0;

Expand Down Expand Up @@ -94,7 +96,7 @@ public async Task<JsonDocument> GetStateAsync(string name, string? partition = n
await using var stream = new MemoryStream();
await using var writer = new Utf8JsonWriter(stream);
var serializer = new ValueSerializer();
serializer.Write(writer, value, new JsonSerializerOptions());
serializer.Write(writer, value, DefaultJsonSerializerOptions);
stream.Position = 0;
await writer.FlushAsync(cancellationToken).ConfigureAwait(false);

Expand All @@ -121,7 +123,7 @@ public async Task<T> GetStateAsync<T>(string name, string? partition = null,
await using var stream = new MemoryStream();
await using var writer = new Utf8JsonWriter(stream);
var serializer = new ValueSerializer();
serializer.Write(writer, value, new JsonSerializerOptions());
serializer.Write(writer, value, DefaultJsonSerializerOptions);
await writer.FlushAsync(cancellationToken).ConfigureAwait(false);
stream.Position = 0;

Expand Down
53 changes: 25 additions & 28 deletions src/EventStore.Client.Streams/InvalidTransactionException.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
using System;
using System.Runtime.Serialization;

namespace EventStore.Client {
/// <summary>
/// Exception thrown if there is an attempt to operate inside a
/// transaction which does not exist.
/// </summary>
public class InvalidTransactionException : Exception {
/// <summary>
/// Constructs a new <see cref="InvalidTransactionException"/>.
/// </summary>
public InvalidTransactionException() {
}
namespace EventStore.Client;

/// <summary>
/// Constructs a new <see cref="InvalidTransactionException"/>.
/// </summary>
public InvalidTransactionException(string message) : base(message) {
}
/// <summary>
/// Exception thrown if there is an attempt to operate inside a
/// transaction which does not exist.
/// </summary>
public class InvalidTransactionException : Exception {
/// <summary>
/// Constructs a new <see cref="InvalidTransactionException"/>.
/// </summary>
public InvalidTransactionException() { }

/// <summary>
/// Constructs a new <see cref="InvalidTransactionException"/>.
/// </summary>
public InvalidTransactionException(string message, Exception innerException) : base(message, innerException) {
}
/// <summary>
/// Constructs a new <see cref="InvalidTransactionException"/>.
/// </summary>
public InvalidTransactionException(string message) : base(message) { }

/// <summary>
/// Constructs a new <see cref="InvalidTransactionException"/>.
/// </summary>
protected InvalidTransactionException(SerializationInfo info, StreamingContext context) : base(info, context) {
}
}
}
/// <summary>
/// Constructs a new <see cref="InvalidTransactionException"/>.
/// </summary>
public InvalidTransactionException(string message, Exception innerException) : base(message, innerException) { }

/// <summary>
/// Constructs a new <see cref="InvalidTransactionException"/>.
/// </summary>
[Obsolete("Obsolete")]
protected InvalidTransactionException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,6 @@
<PropertyGroup>
<Description>The GRPC client API for managing users in Event Store. Get the open source or commercial versions of Event Store server from https://eventstore.com/</Description>
</PropertyGroup>
<ItemGroup>
<Folder Include="Infrastructure\" />
</ItemGroup>
<ItemGroup>
<Compile Update="..\EventStore.Client.Common\AsyncStreamReaderExtensions.cs">
<Link>Infrastructure\AsyncStreamReaderExtensions.cs</Link>
</Compile>
<Compile Update="..\EventStore.Client.Common\Constants.cs">
<Link>Infrastructure\Constants.cs</Link>
</Compile>
<Compile Update="..\EventStore.Client.Common\EpochExtensions.cs">
<Link>Infrastructure\EpochExtensions.cs</Link>
</Compile>
<Compile Update="..\EventStore.Client.Common\EventStoreCallOptions.cs">
<Link>Infrastructure\EventStoreCallOptions.cs</Link>
</Compile>
<Compile Update="..\EventStore.Client.Common\MetadataExtensions.cs">
<Link>Infrastructure\MetadataExtensions.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Remove="EventStore.Client.UserManagement.csproj.DotSettings" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 33512f3

Please sign in to comment.