diff --git a/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj b/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj index 54506df0..8880a7a6 100644 --- a/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj +++ b/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj @@ -1,14 +1,14 @@ - - Exe - netcoreapp3.1 - false - + + Exe + netcoreapp3.1 + false + - - - - + + + + diff --git a/examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs b/examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs index ea3d7de5..eafba6d1 100644 --- a/examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs +++ b/examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs @@ -9,6 +9,7 @@ public class PersonAndFilmsResponse public class PersonContent { public string Name { get; set; } + public FilmConnectionContent FilmConnection { get; set; } public class FilmConnectionContent diff --git a/examples/GraphQL.Client.Example/Program.cs b/examples/GraphQL.Client.Example/Program.cs index 2ef597ec..0bfd14b1 100644 --- a/examples/GraphQL.Client.Example/Program.cs +++ b/examples/GraphQL.Client.Example/Program.cs @@ -7,13 +7,10 @@ namespace GraphQL.Client.Example { - public class Program { - - public static async Task Main(string[] args) + public static async Task Main() { - _ = args; using var graphQLClient = new GraphQLHttpClient("https://swapi.apis.guru/", new NewtonsoftJsonSerializer()); var personAndFilmsRequest = new GraphQLRequest @@ -49,6 +46,5 @@ query PersonAndFilms($id: ID) { Console.WriteLine("Press any key to quit..."); Console.ReadKey(); } - } } diff --git a/root.props b/root.props index 2c0a5b7d..17bd287e 100644 --- a/root.props +++ b/root.props @@ -1,39 +1,38 @@ - - - Deinok,Alexander Rose,graphql-dotnet - A GraphQL Client for .NET Standard - True - True - 8.0 - en-US - CS0618;CS1591;CS1701;CS8618;CS8632;NU5048;NU5105;NU5125 - annotations - icon.png - LICENSE.txt - https://github.com/graphql-dotnet/graphql-client - true - GraphQL - git - https://github.com/graphql-dotnet/graphql-client - True - 4 - + + Deinok,Alexander Rose,graphql-dotnet + A GraphQL Client for .NET Standard + True + True + 8.0 + en-US + $(NoWarn);CS1591;NU5048;NU5105;NU5125 + annotations + icon.png + LICENSE.txt + https://github.com/graphql-dotnet/graphql-client + true + GraphQL + git + https://github.com/graphql-dotnet/graphql-client + True + 4 + - - - PreserveNewest - true - LICENSE.txt - false - - - PreserveNewest - true - icon.png - false - - + + + PreserveNewest + true + LICENSE.txt + false + + + PreserveNewest + true + icon.png + false + + diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj b/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj index 0863c38f..d1980775 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj @@ -1,13 +1,14 @@ - + + - + Abstractions for the Websocket transport used in GraphQL.Client netstandard2.0 - + - - - + + + diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketMessageType.cs b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketMessageType.cs index 6dd7f019..daa83114 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketMessageType.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketMessageType.cs @@ -84,6 +84,5 @@ public static class GraphQLWebSocketMessageType /// id: string : operation id /// public const string GQL_STOP = "stop"; // Client -> Server - } } diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs index 7c986acc..623e4271 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs @@ -4,7 +4,6 @@ namespace GraphQL.Client.Abstractions.Websocket { - /// /// A Subscription Request /// @@ -50,7 +49,7 @@ public GraphQLRequest Payload public Task SendTask() => _tcs.Task; /// - /// gets called when the send operation for this request has completed sucessfully + /// gets called when the send operation for this request has completed successfully /// public void SendCompleted() => _tcs.SetResult(true); @@ -109,7 +108,5 @@ public override int GetHashCode() /// public static bool operator !=(GraphQLWebSocketRequest request1, GraphQLWebSocketRequest request2) => !(request1 == request2); - } - } diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketResponse.cs b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketResponse.cs index d6c69a70..390834da 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketResponse.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketResponse.cs @@ -3,13 +3,11 @@ namespace GraphQL.Client.Abstractions.Websocket { - /// /// A Subscription Response /// public class GraphQLWebSocketResponse : IEquatable { - /// /// The Identifier of the Response /// @@ -65,7 +63,6 @@ public override int GetHashCode() /// public static bool operator !=(GraphQLWebSocketResponse response1, GraphQLWebSocketResponse response2) => !(response1 == response2); - } public class GraphQLWebSocketResponse : GraphQLWebSocketResponse, IEquatable> diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebsocketConnectionState.cs b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebsocketConnectionState.cs index 148436cd..c5fd3107 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebsocketConnectionState.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebsocketConnectionState.cs @@ -3,7 +3,9 @@ namespace GraphQL.Client.Abstractions.Websocket public enum GraphQLWebsocketConnectionState { Disconnected, + Connecting, + Connected } } diff --git a/src/GraphQL.Client.Abstractions.Websocket/IGraphQLWebsocketJsonSerializer.cs b/src/GraphQL.Client.Abstractions.Websocket/IGraphQLWebsocketJsonSerializer.cs index 23536db5..5e3d58ec 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/IGraphQLWebsocketJsonSerializer.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/IGraphQLWebsocketJsonSerializer.cs @@ -12,7 +12,7 @@ public interface IGraphQLWebsocketJsonSerializer : IGraphQLJsonSerializer byte[] SerializeToBytes(GraphQLWebSocketRequest request); Task DeserializeToWebsocketResponseWrapperAsync(Stream stream); - GraphQLWebSocketResponse> DeserializeToWebsocketResponse(byte[] bytes); + GraphQLWebSocketResponse> DeserializeToWebsocketResponse(byte[] bytes); } } diff --git a/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj b/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj index 63e9aa89..d7678b66 100644 --- a/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj +++ b/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj @@ -1,19 +1,18 @@ - + - - Abstractions for GraphQL.Client - GraphQL.Client.Abstractions - netstandard2.0 - + + Abstractions for GraphQL.Client + netstandard2.0 + - - - + + + - - - + + + diff --git a/src/GraphQL.Client.Abstractions/IGraphQLClient.cs b/src/GraphQL.Client.Abstractions/IGraphQLClient.cs index df0557af..0508f8b5 100644 --- a/src/GraphQL.Client.Abstractions/IGraphQLClient.cs +++ b/src/GraphQL.Client.Abstractions/IGraphQLClient.cs @@ -5,10 +5,8 @@ namespace GraphQL.Client.Abstractions { - public interface IGraphQLClient : IDisposable { - Task> SendQueryAsync(GraphQLRequest request, CancellationToken cancellationToken = default); Task> SendMutationAsync(GraphQLRequest request, CancellationToken cancellationToken = default); @@ -30,9 +28,8 @@ public interface IGraphQLClient : IDisposable /// Any exception thrown by will cause the sequence to fail. /// /// the GraphQL request for this subscription - /// an external handler for all s occuring within the sequence + /// an external handler for all s occurring within the sequence /// an observable stream for the specified subscription IObservable> CreateSubscriptionStream(GraphQLRequest request, Action exceptionHandler); } - } diff --git a/src/GraphQL.Client.Abstractions/IGraphQLJsonSerializer.cs b/src/GraphQL.Client.Abstractions/IGraphQLJsonSerializer.cs index 5c119e4a..fa21dbac 100644 --- a/src/GraphQL.Client.Abstractions/IGraphQLJsonSerializer.cs +++ b/src/GraphQL.Client.Abstractions/IGraphQLJsonSerializer.cs @@ -8,9 +8,6 @@ public interface IGraphQLJsonSerializer { string SerializeToString(GraphQLRequest request); - Task> DeserializeFromUtf8StreamAsync(Stream stream, - CancellationToken cancellationToken); + Task> DeserializeFromUtf8StreamAsync(Stream stream, CancellationToken cancellationToken); } - - } diff --git a/src/GraphQL.Client.LocalExecution/ExecutionResultExtensions.cs b/src/GraphQL.Client.LocalExecution/ExecutionResultExtensions.cs deleted file mode 100644 index 32133976..00000000 --- a/src/GraphQL.Client.LocalExecution/ExecutionResultExtensions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace GraphQL.Client.LocalExecution -{ - public class ExecutionResultExtensions - { - - } -} diff --git a/src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj b/src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj index 927c3470..ebef7ea0 100644 --- a/src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj +++ b/src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj @@ -1,20 +1,20 @@ - + - - A GraphQL Client which executes the queries directly on a provided GraphQL schema using graphql-dotnet - netstandard2.0 - + + A GraphQL Client which executes the queries directly on a provided GraphQL schema using graphql-dotnet + netstandard2.0 + - - - - - + + + + + - - - + + + diff --git a/src/GraphQL.Client.LocalExecution/GraphQLEnumConverter.cs b/src/GraphQL.Client.LocalExecution/GraphQLEnumConverter.cs index 89bbcfc0..a02cf935 100644 --- a/src/GraphQL.Client.LocalExecution/GraphQLEnumConverter.cs +++ b/src/GraphQL.Client.LocalExecution/GraphQLEnumConverter.cs @@ -34,5 +34,4 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s } } } - } diff --git a/src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs b/src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs index c055cecb..d458d20e 100644 --- a/src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs +++ b/src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs @@ -22,10 +22,8 @@ public static GraphQLLocalExecutionClient New(TSchema schema, => new GraphQLLocalExecutionClient(schema, serializer); } - public class GraphQLLocalExecutionClient : IGraphQLClient where TSchema : ISchema { - private static readonly JsonSerializerSettings _variablesSerializerSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, @@ -38,8 +36,8 @@ public class GraphQLLocalExecutionClient : IGraphQLClient where TSchema }; public TSchema Schema { get; } - public IGraphQLJsonSerializer Serializer { get; } + public IGraphQLJsonSerializer Serializer { get; } private readonly DocumentExecuter _documentExecuter; diff --git a/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj b/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj index 530f1757..4bbcb784 100644 --- a/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj +++ b/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj @@ -1,5 +1,6 @@ - + + A serializer implementation for GraphQL.Client using Newtonsoft.Json as underlying JSON library diff --git a/src/GraphQL.Client.Serializer.Newtonsoft/MapConverter.cs b/src/GraphQL.Client.Serializer.Newtonsoft/MapConverter.cs index 10a687f4..3caefd5f 100644 --- a/src/GraphQL.Client.Serializer.Newtonsoft/MapConverter.cs +++ b/src/GraphQL.Client.Serializer.Newtonsoft/MapConverter.cs @@ -12,13 +12,12 @@ public override void WriteJson(JsonWriter writer, Map value, JsonSerializer seri throw new NotImplementedException( "This converter currently is only intended to be used to read a JSON object into a strongly-typed representation."); - public override Map ReadJson(JsonReader reader, Type objectType, Map existingValue, - bool hasExistingValue, JsonSerializer serializer) + public override Map ReadJson(JsonReader reader, Type objectType, Map existingValue, bool hasExistingValue, JsonSerializer serializer) { var rootToken = JToken.ReadFrom(reader); if (rootToken is JObject) { - return ReadDictionary(rootToken); + return (Map)ReadDictionary(rootToken, new Map()); } else throw new ArgumentException("This converter can only parse when the root element is a JSON Object."); @@ -27,7 +26,7 @@ public override Map ReadJson(JsonReader reader, Type objectType, Map existingVal private object? ReadToken(JToken? token) => token switch { - JObject jObject => ReadDictionary>(jObject), + JObject jObject => ReadDictionary(jObject, new Dictionary()), JArray jArray => ReadArray(jArray).ToList(), JValue jValue => jValue.Value, JConstructor _ => throw new ArgumentOutOfRangeException(nameof(token.Type), @@ -39,16 +38,15 @@ public override Map ReadJson(JsonReader reader, Type objectType, Map existingVal _ => throw new ArgumentOutOfRangeException(nameof(token.Type)) }; - private TDictionary ReadDictionary(JToken element) where TDictionary : Dictionary + private Dictionary ReadDictionary(JToken element, Dictionary to) { - var result = Activator.CreateInstance(); foreach (var property in ((JObject)element).Properties()) { if (IsUnsupportedJTokenType(property.Value.Type)) continue; - result[property.Name] = ReadToken(property.Value); + to[property.Name] = ReadToken(property.Value); } - return result; + return to; } private IEnumerable ReadArray(JArray element) diff --git a/src/GraphQL.Client.Serializer.Newtonsoft/NewtonsoftJsonSerializer.cs b/src/GraphQL.Client.Serializer.Newtonsoft/NewtonsoftJsonSerializer.cs index 99936421..5ec06c1a 100644 --- a/src/GraphQL.Client.Serializer.Newtonsoft/NewtonsoftJsonSerializer.cs +++ b/src/GraphQL.Client.Serializer.Newtonsoft/NewtonsoftJsonSerializer.cs @@ -49,7 +49,6 @@ public GraphQLWebSocketResponse> DeserializeToWebsock public Task> DeserializeFromUtf8StreamAsync(Stream stream, CancellationToken cancellationToken) => DeserializeFromUtf8Stream>(stream); - private Task DeserializeFromUtf8Stream(Stream stream) { using var sr = new StreamReader(stream); @@ -57,6 +56,5 @@ private Task DeserializeFromUtf8Stream(Stream stream) var serializer = JsonSerializer.Create(JsonSerializerSettings); return Task.FromResult(serializer.Deserialize(reader)); } - } } diff --git a/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj b/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj index 2713516e..9433b8dd 100644 --- a/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj +++ b/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj @@ -1,5 +1,5 @@ - + @@ -7,12 +7,12 @@ netstandard2.0;netcoreapp3.1 - - - + + + - - - + + + diff --git a/src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs b/src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs index 78b5811b..4a26f6f2 100644 --- a/src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs +++ b/src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs @@ -8,7 +8,6 @@ namespace GraphQL.Client.Serializer.SystemTextJson { - /// /// class for converting immutable objects, derived from https://github.com/manne/obviously/blob/master/src/system.text.json/Core/ImmutableConverter.cs /// diff --git a/src/GraphQL.Client.Serializer.SystemTextJson/JsonSerializerOptionsExtensions.cs b/src/GraphQL.Client.Serializer.SystemTextJson/JsonSerializerOptionsExtensions.cs index e2d914c0..bc2ddc14 100644 --- a/src/GraphQL.Client.Serializer.SystemTextJson/JsonSerializerOptionsExtensions.cs +++ b/src/GraphQL.Client.Serializer.SystemTextJson/JsonSerializerOptionsExtensions.cs @@ -4,8 +4,7 @@ namespace GraphQL.Client.Serializer.SystemTextJson { public static class JsonSerializerOptionsExtensions { - public static JsonSerializerOptions SetupImmutableConverter( - this JsonSerializerOptions options) + public static JsonSerializerOptions SetupImmutableConverter(this JsonSerializerOptions options) { options.Converters.Add(new ImmutableConverter()); return options; diff --git a/src/GraphQL.Client/GraphQL.Client.csproj b/src/GraphQL.Client/GraphQL.Client.csproj index df3edd60..febf2911 100644 --- a/src/GraphQL.Client/GraphQL.Client.csproj +++ b/src/GraphQL.Client/GraphQL.Client.csproj @@ -1,31 +1,31 @@ - + - - netstandard2.0;net461 - GraphQL.Client.Http - + + netstandard2.0;net461 + GraphQL.Client.Http + - - NETSTANDARD - + + NETSTANDARD + - - NETFRAMEWORK - + + NETFRAMEWORK + - - + + + + + + - - - - - - - - + + + + diff --git a/src/GraphQL.Client/GraphQLHttpClient.cs b/src/GraphQL.Client/GraphQLHttpClient.cs index 1777e0b5..5d8453ef 100644 --- a/src/GraphQL.Client/GraphQLHttpClient.cs +++ b/src/GraphQL.Client/GraphQLHttpClient.cs @@ -11,10 +11,8 @@ namespace GraphQL.Client.Http { - public class GraphQLHttpClient : IGraphQLClient { - private readonly GraphQLHttpWebSocket _graphQlHttpWebSocket; private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); private readonly ConcurrentDictionary, object> _subscriptionStreams = new ConcurrentDictionary, object>(); @@ -42,8 +40,7 @@ public class GraphQLHttpClient : IGraphQLClient /// /// the websocket connection state /// - public IObservable WebsocketConnectionState => - _graphQlHttpWebSocket.ConnectionState; + public IObservable WebsocketConnectionState => _graphQlHttpWebSocket.ConnectionState; #region Constructors @@ -156,7 +153,6 @@ private Uri GetWebSocketUri() #endregion - #region IDisposable /// @@ -168,26 +164,27 @@ public void Dispose() { if (!_disposed) { - _dispose(); + _disposed = true; + Dispose(true); } } } - private bool _disposed = false; + private volatile bool _disposed; private readonly object _disposeLocker = new object(); - private void _dispose() + protected virtual void Dispose(bool disposing) { - _disposed = true; - Debug.WriteLine($"disposing GraphQLHttpClient on endpoint {Options.EndPoint}"); - _cancellationTokenSource.Cancel(); - HttpClient.Dispose(); - _graphQlHttpWebSocket.Dispose(); - _cancellationTokenSource.Dispose(); + if (disposing) + { + Debug.WriteLine($"Disposing GraphQLHttpClient on endpoint {Options.EndPoint}"); + _cancellationTokenSource.Cancel(); + HttpClient.Dispose(); + _graphQlHttpWebSocket.Dispose(); + _cancellationTokenSource.Dispose(); + } } #endregion - } - } diff --git a/src/GraphQL.Client/GraphQLHttpClientExtensions.cs b/src/GraphQL.Client/GraphQLHttpClientExtensions.cs index 99886c0c..31f29785 100644 --- a/src/GraphQL.Client/GraphQLHttpClientExtensions.cs +++ b/src/GraphQL.Client/GraphQLHttpClientExtensions.cs @@ -15,7 +15,7 @@ public static class GraphQLHttpClientExtensions /// /// the GraphQL client /// the GraphQL request for this subscription - /// an external handler for all s occuring within the sequence + /// an external handler for all s occurring within the sequence /// an observable stream for the specified subscription public static IObservable> CreateSubscriptionStream(this IGraphQLClient client, GraphQLRequest request, Action webSocketExceptionHandler) => diff --git a/src/GraphQL.Client/GraphQLHttpClientOptions.cs b/src/GraphQL.Client/GraphQLHttpClientOptions.cs index 0c6df2ee..6e2c3a46 100644 --- a/src/GraphQL.Client/GraphQLHttpClientOptions.cs +++ b/src/GraphQL.Client/GraphQLHttpClientOptions.cs @@ -6,13 +6,11 @@ namespace GraphQL.Client.Http { - /// /// The Options that the will use /// public class GraphQLHttpClientOptions { - /// /// The GraphQL EndPoint to be used /// diff --git a/src/GraphQL.Client/GraphQLHttpRequest.cs b/src/GraphQL.Client/GraphQLHttpRequest.cs index ec5c5fd8..00f90d4a 100644 --- a/src/GraphQL.Client/GraphQLHttpRequest.cs +++ b/src/GraphQL.Client/GraphQLHttpRequest.cs @@ -6,7 +6,6 @@ namespace GraphQL.Client.Http { - public class GraphQLHttpRequest : GraphQLRequest { public GraphQLHttpRequest() @@ -42,7 +41,9 @@ public virtual HttpRequestMessage ToHttpRequestMessage(GraphQLHttpClientOptions Content = new StringContent(serializer.SerializeToString(this), Encoding.UTF8, options.MediaType) }; +#pragma warning disable CS0618 // Type or member is obsolete PreprocessHttpRequestMessage(message); +#pragma warning restore CS0618 // Type or member is obsolete return message; } } diff --git a/src/GraphQL.Client/GraphQLHttpResponse.cs b/src/GraphQL.Client/GraphQLHttpResponse.cs index 73a4cea8..b4b09784 100644 --- a/src/GraphQL.Client/GraphQLHttpResponse.cs +++ b/src/GraphQL.Client/GraphQLHttpResponse.cs @@ -4,7 +4,6 @@ namespace GraphQL.Client.Http { - public class GraphQLHttpResponse : GraphQLResponse { public GraphQLHttpResponse(GraphQLResponse response, HttpResponseHeaders responseHeaders, HttpStatusCode statusCode) @@ -17,6 +16,7 @@ public GraphQLHttpResponse(GraphQLResponse response, HttpResponseHeaders resp } public HttpResponseHeaders ResponseHeaders { get; set; } + public HttpStatusCode StatusCode { get; set; } } @@ -25,7 +25,7 @@ public static class GraphQLResponseExtensions public static GraphQLHttpResponse ToGraphQLHttpResponse(this GraphQLResponse response, HttpResponseHeaders responseHeaders, HttpStatusCode statusCode) => new GraphQLHttpResponse(response, responseHeaders, statusCode); /// - /// Casts to . Throws ig the cast fails. + /// Casts to . Throws if the cast fails. /// /// /// diff --git a/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs b/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs index 227b53cd..901fd919 100644 --- a/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs +++ b/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs @@ -48,7 +48,6 @@ internal class GraphQLHttpWebSocket : IDisposable #endregion - #region Public properties /// @@ -73,7 +72,6 @@ internal class GraphQLHttpWebSocket : IDisposable #endregion - public GraphQLHttpWebSocket(Uri webSocketUri, GraphQLHttpClient client) { _internalCancellationToken = _internalCancellationTokenSource.Token; @@ -89,7 +87,6 @@ public GraphQLHttpWebSocket(Uri webSocketUri, GraphQLHttpClient client) .Subscribe(async request => await SendWebSocketRequestAsync(request)); } - #region Send requests /// @@ -492,7 +489,7 @@ private IObservable GetMessageStream() => Observable.Using(() => new EventLoopScheduler(), scheduler => Observable.Create(async observer => { - // make sure the websocket ist connected + // make sure the websocket is connected await InitializeWebSocket(); // subscribe observer to message stream var subscription = new CompositeDisposable(_incomingMessages.ObserveOn(scheduler).Subscribe(observer)) @@ -593,6 +590,7 @@ private async Task CloseAsync() } #region IDisposable + public void Dispose() => Complete(); /// @@ -638,6 +636,7 @@ private async Task CompleteAsync() Debug.WriteLine($"websocket {_clientWebSocket.GetHashCode()} disposed"); } + #endregion } } diff --git a/src/GraphQL.Primitives/GraphQL.Primitives.csproj b/src/GraphQL.Primitives/GraphQL.Primitives.csproj index 53d39859..1c324df3 100644 --- a/src/GraphQL.Primitives/GraphQL.Primitives.csproj +++ b/src/GraphQL.Primitives/GraphQL.Primitives.csproj @@ -1,11 +1,11 @@ - - - - GraphQL basic types - GraphQL - netstandard2.0 - + + + GraphQL basic types + GraphQL + netstandard2.0 + + diff --git a/src/GraphQL.Primitives/GraphQLError.cs b/src/GraphQL.Primitives/GraphQLError.cs index 0bfe834c..9b7cfc99 100644 --- a/src/GraphQL.Primitives/GraphQLError.cs +++ b/src/GraphQL.Primitives/GraphQLError.cs @@ -5,13 +5,11 @@ namespace GraphQL { - /// /// Represents a GraphQL Error of a GraphQL Query /// public class GraphQLError : IEquatable { - /// /// The locations of the error /// @@ -41,8 +39,7 @@ public class GraphQLError : IEquatable /// /// The object to compare with this instance /// true if obj is an instance of and equals the value of the instance; otherwise, false - public override bool Equals(object? obj) => - Equals(obj as GraphQLError); + public override bool Equals(object? obj) => Equals(obj as GraphQLError); /// /// Returns a value that indicates whether this instance is equal to a specified object @@ -117,7 +114,5 @@ public override int GetHashCode() /// true if left and right are unequal; otherwise, false public static bool operator !=(GraphQLError? left, GraphQLError? right) => !EqualityComparer.Default.Equals(left, right); - } - } diff --git a/src/GraphQL.Primitives/GraphQLLocation.cs b/src/GraphQL.Primitives/GraphQLLocation.cs index c1fe6cee..9464817a 100644 --- a/src/GraphQL.Primitives/GraphQLLocation.cs +++ b/src/GraphQL.Primitives/GraphQLLocation.cs @@ -3,13 +3,11 @@ namespace GraphQL { - /// /// Represents a GraphQL Location of a GraphQL Query /// public sealed class GraphQLLocation : IEquatable { - /// /// The Column /// @@ -65,7 +63,5 @@ public override int GetHashCode() => /// true if left and right are unequal; otherwise, false public static bool operator !=(GraphQLLocation? left, GraphQLLocation? right) => !EqualityComparer.Default.Equals(left, right); - } - } diff --git a/src/GraphQL.Primitives/GraphQLRequest.cs b/src/GraphQL.Primitives/GraphQLRequest.cs index a36dae38..72033552 100644 --- a/src/GraphQL.Primitives/GraphQLRequest.cs +++ b/src/GraphQL.Primitives/GraphQLRequest.cs @@ -4,7 +4,6 @@ namespace GraphQL { - /// /// A GraphQL request /// @@ -110,6 +109,4 @@ public override int GetHashCode() /// true if left and right are unequal; otherwise, false public static bool operator !=(GraphQLRequest? left, GraphQLRequest? right) => !(left == right); } - - } diff --git a/src/GraphQL.Primitives/GraphQLResponse.cs b/src/GraphQL.Primitives/GraphQLResponse.cs index 24d3a4aa..1c1af7de 100644 --- a/src/GraphQL.Primitives/GraphQLResponse.cs +++ b/src/GraphQL.Primitives/GraphQLResponse.cs @@ -5,10 +5,8 @@ namespace GraphQL { - public class GraphQLResponse : IGraphQLResponse, IEquatable?> { - [DataMember(Name = "data")] public T Data { get; set; } object IGraphQLResponse.Data => Data; @@ -87,13 +85,8 @@ public override int GetHashCode() } } - public static bool operator ==(GraphQLResponse? response1, GraphQLResponse? response2) => EqualityComparer?>.Default.Equals(response1, response2); public static bool operator !=(GraphQLResponse? response1, GraphQLResponse? response2) => !(response1 == response2); - } - - - } diff --git a/src/GraphQL.Primitives/Map.cs b/src/GraphQL.Primitives/Map.cs index cba91bee..9c4f503b 100644 --- a/src/GraphQL.Primitives/Map.cs +++ b/src/GraphQL.Primitives/Map.cs @@ -2,7 +2,6 @@ namespace GraphQL { - /// /// A type equivalent to a javascript map. Create a custom json converter for this class to customize your serializers behaviour /// diff --git a/src/src.props b/src/src.props index d7ed8515..91497142 100644 --- a/src/src.props +++ b/src/src.props @@ -1,12 +1,11 @@ - - + - - true - 8.0 - + + true + 8.0 + @@ -16,23 +15,23 @@ - - false - false - false - false + + false + false + false + false - $(GitVersion_FullSemVer) - $(GitVersion_MajorMinorPatch) - $(GitVersion_NuGetPreReleaseTag) - $(GitVersion_PreReleaseTag) - $(GitVersion_NuGetVersion) - $(GitVersion_FullSemVer) - $(GitVersion_InformationalVersion) - $(GitVersion_AssemblySemVer) - $(GitVersion_AssemblySemFileVer) - $(GitVersion_BranchName) - $(GitVersion_Sha) - + $(GitVersion_FullSemVer) + $(GitVersion_MajorMinorPatch) + $(GitVersion_NuGetPreReleaseTag) + $(GitVersion_PreReleaseTag) + $(GitVersion_NuGetVersion) + $(GitVersion_FullSemVer) + $(GitVersion_InformationalVersion) + $(GitVersion_AssemblySemVer) + $(GitVersion_AssemblySemFileVer) + $(GitVersion_BranchName) + $(GitVersion_Sha) + diff --git a/tests/GraphQL.Client.Serializer.Tests/BaseSerializeNoCamelCaseTest.cs b/tests/GraphQL.Client.Serializer.Tests/BaseSerializeNoCamelCaseTest.cs index 5547e136..7ef81660 100644 --- a/tests/GraphQL.Client.Serializer.Tests/BaseSerializeNoCamelCaseTest.cs +++ b/tests/GraphQL.Client.Serializer.Tests/BaseSerializeNoCamelCaseTest.cs @@ -13,9 +13,10 @@ namespace GraphQL.Client.Serializer.Tests { public abstract class BaseSerializeNoCamelCaseTest { - public IGraphQLWebsocketJsonSerializer Serializer { get; } + public IGraphQLClient ChatClient { get; } + public IGraphQLClient StarWarsClient { get; } protected BaseSerializeNoCamelCaseTest(IGraphQLWebsocketJsonSerializer serializer) @@ -41,7 +42,6 @@ public void SerializeToBytesTest(string expectedJson, GraphQLWebSocketRequest re json.Should().Be(expectedJson.RemoveWhitespace()); } - [Fact] public async void WorksWithoutCamelCaseNamingStrategy() { diff --git a/tests/GraphQL.Client.Serializer.Tests/BaseSerializerTest.cs b/tests/GraphQL.Client.Serializer.Tests/BaseSerializerTest.cs index 940b7392..5811823c 100644 --- a/tests/GraphQL.Client.Serializer.Tests/BaseSerializerTest.cs +++ b/tests/GraphQL.Client.Serializer.Tests/BaseSerializerTest.cs @@ -18,7 +18,9 @@ namespace GraphQL.Client.Serializer.Tests public abstract class BaseSerializerTest { public IGraphQLWebsocketJsonSerializer Serializer { get; } + public IGraphQLClient ChatClient { get; } + public IGraphQLClient StarWarsClient { get; } protected BaseSerializerTest(IGraphQLWebsocketJsonSerializer serializer) @@ -83,7 +85,6 @@ public async void CanDeserializeExtensions() response.Errors[0].Extensions["data"].Should().BeEquivalentTo(ChatQuery.TestExtensions); } - [Theory] [ClassData(typeof(StarWarsHumans))] public async void CanDoSerializationWithAnonymousTypes(int id, string name) diff --git a/tests/GraphQL.Client.Serializer.Tests/GraphQL.Client.Serializer.Tests.csproj b/tests/GraphQL.Client.Serializer.Tests/GraphQL.Client.Serializer.Tests.csproj index 87c5b880..3a5af98e 100644 --- a/tests/GraphQL.Client.Serializer.Tests/GraphQL.Client.Serializer.Tests.csproj +++ b/tests/GraphQL.Client.Serializer.Tests/GraphQL.Client.Serializer.Tests.csproj @@ -1,24 +1,11 @@ + + netcoreapp3.1 - false - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/tests/GraphQL.Client.Tests.Common/Chat/AddMessageMutationResult.cs b/tests/GraphQL.Client.Tests.Common/Chat/AddMessageMutationResult.cs index 385e537b..70a51a72 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/AddMessageMutationResult.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/AddMessageMutationResult.cs @@ -3,6 +3,7 @@ namespace GraphQL.Client.Tests.Common.Chat public class AddMessageMutationResult { public AddMessageContent AddMessage { get; set; } + public class AddMessageContent { public string Content { get; set; } diff --git a/tests/GraphQL.Client.Tests.Common/Chat/AddMessageVariables.cs b/tests/GraphQL.Client.Tests.Common/Chat/AddMessageVariables.cs index 3a6ae10c..0a330007 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/AddMessageVariables.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/AddMessageVariables.cs @@ -4,12 +4,14 @@ namespace GraphQL.Client.Tests.Common.Chat { public class AddMessageVariables { - public AddMessageInput Input { get; set; } + public class AddMessageInput { public string FromId { get; set; } + public string Content { get; set; } + public DateTime SentAt { get; set; } } } diff --git a/tests/GraphQL.Client.Tests.Common/Chat/GraphQLClientChatExtensions.cs b/tests/GraphQL.Client.Tests.Common/Chat/GraphQLClientChatExtensions.cs index 261f5722..f4417860 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/GraphQLClientChatExtensions.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/GraphQLClientChatExtensions.cs @@ -44,6 +44,5 @@ public static Task> JoinDeveloperUs }); return client.SendMutationAsync(graphQLRequest); } - } } diff --git a/tests/GraphQL.Client.Tests.Common/Chat/JoinDeveloperMutationResult.cs b/tests/GraphQL.Client.Tests.Common/Chat/JoinDeveloperMutationResult.cs index c1b02444..c9910444 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/JoinDeveloperMutationResult.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/JoinDeveloperMutationResult.cs @@ -3,9 +3,11 @@ namespace GraphQL.Client.Tests.Common.Chat public class JoinDeveloperMutationResult { public JoinContent Join { get; set; } + public class JoinContent { public string DisplayName { get; set; } + public string Id { get; set; } } } diff --git a/tests/GraphQL.Client.Tests.Common/Chat/Schema/ChatQuery.cs b/tests/GraphQL.Client.Tests.Common/Chat/Schema/ChatQuery.cs index 0eb335ef..e60bf97e 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/Schema/ChatQuery.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/Schema/ChatQuery.cs @@ -7,7 +7,6 @@ namespace GraphQL.Client.Tests.Common.Chat.Schema { public class ChatQuery : ObjectGraphType { - public static readonly Dictionary TestExtensions = new Dictionary { {"extension1", "hello world"}, {"another extension", 4711}, @@ -19,7 +18,6 @@ public class ChatQuery : ObjectGraphType public readonly ManualResetEventSlim LongRunningQueryBlocker = new ManualResetEventSlim(); public readonly ManualResetEventSlim WaitingOnQueryBlocker = new ManualResetEventSlim(); - public ChatQuery(IChat chat) { Name = "ChatQuery"; diff --git a/tests/GraphQL.Client.Tests.Common/Common.cs b/tests/GraphQL.Client.Tests.Common/Common.cs index 3bfd2409..97dd30fe 100644 --- a/tests/GraphQL.Client.Tests.Common/Common.cs +++ b/tests/GraphQL.Client.Tests.Common/Common.cs @@ -17,6 +17,7 @@ public static StarWarsSchema GetStarWarsSchema() services.AddStarWarsSchema(); return services.BuildServiceProvider().GetRequiredService(); } + public static ChatSchema GetChatSchema() { var services = new ServiceCollection(); diff --git a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj index f37d033b..c1806363 100644 --- a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj +++ b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj @@ -2,7 +2,6 @@ netstandard2.0 - false diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs b/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs index a6a4e50f..6aa7284a 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs @@ -12,7 +12,7 @@ public class CallbackMonitor private readonly ManualResetEventSlim _callbackInvoked = new ManualResetEventSlim(); /// - /// The timeout for . Defaults to 1 s + /// The timeout for . Defaults to 1 second. /// public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(1); @@ -20,6 +20,7 @@ public class CallbackMonitor /// Indicates that an update has been received since the last /// public bool CallbackInvoked => _callbackInvoked.IsSet; + /// /// The last payload which was received. /// @@ -37,7 +38,7 @@ public void Invoke(T param) /// public void Reset() { - LastPayload = default(T); + LastPayload = default; _callbackInvoked.Reset(); } diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/ConcurrentTaskWrapper.cs b/tests/GraphQL.Client.Tests.Common/Helpers/ConcurrentTaskWrapper.cs index 6af84092..c16e1744 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/ConcurrentTaskWrapper.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/ConcurrentTaskWrapper.cs @@ -3,7 +3,6 @@ namespace GraphQL.Client.Tests.Common.Helpers { - public class ConcurrentTaskWrapper { public static ConcurrentTaskWrapper New(Func> createTask) => new ConcurrentTaskWrapper(createTask); diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/MiscellaneousExtensions.cs b/tests/GraphQL.Client.Tests.Common/Helpers/MiscellaneousExtensions.cs index b769399b..dcbb6db9 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/MiscellaneousExtensions.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/MiscellaneousExtensions.cs @@ -22,7 +22,5 @@ public static CallbackMonitor ConfigureMonitorForOnWebsocketC }; return tester; } - - } } diff --git a/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj b/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj index b09be5dd..3cc7fd29 100644 --- a/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj +++ b/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj @@ -1,24 +1,16 @@ - + + + netcoreapp3.1 - - false - - - + - - - - all - runtime; build; native; contentfiles; analyzers - @@ -28,5 +20,4 @@ - diff --git a/tests/GraphQL.Integration.Tests/Helpers/IntegrationServerTestFixture.cs b/tests/GraphQL.Integration.Tests/Helpers/IntegrationServerTestFixture.cs index e70751b7..25773b47 100644 --- a/tests/GraphQL.Integration.Tests/Helpers/IntegrationServerTestFixture.cs +++ b/tests/GraphQL.Integration.Tests/Helpers/IntegrationServerTestFixture.cs @@ -13,7 +13,9 @@ namespace GraphQL.Integration.Tests.Helpers public abstract class IntegrationServerTestFixture { public int Port { get; private set; } + public IWebHost Server { get; private set; } + public abstract IGraphQLWebsocketJsonSerializer Serializer { get; } public IntegrationServerTestFixture() diff --git a/tests/GraphQL.Integration.Tests/Helpers/WebHostHelpers.cs b/tests/GraphQL.Integration.Tests/Helpers/WebHostHelpers.cs index 81ff2248..0bdb0e8c 100644 --- a/tests/GraphQL.Integration.Tests/Helpers/WebHostHelpers.cs +++ b/tests/GraphQL.Integration.Tests/Helpers/WebHostHelpers.cs @@ -55,7 +55,9 @@ public TestServerSetup(IGraphQLWebsocketJsonSerializer serializer) } public int Port { get; } + public IWebHost Server { get; set; } + public IGraphQLWebsocketJsonSerializer Serializer { get; set; } public GraphQLHttpClient GetStarWarsClient(bool requestsViaWebsocket = false) diff --git a/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs b/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs index 550eb6a0..5855e626 100644 --- a/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs +++ b/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs @@ -15,10 +15,8 @@ namespace GraphQL.Integration.Tests.QueryAndMutationTests { - public abstract class Base : IAsyncLifetime { - protected IntegrationServerTestFixture Fixture; protected GraphQLHttpClient StarWarsClient; protected GraphQLHttpClient ChatClient; @@ -175,7 +173,9 @@ public async void PreprocessHttpRequestMessageIsCalled() var callbackTester = new CallbackMonitor(); var graphQLRequest = new GraphQLHttpRequest($"{{ human(id: \"1\") {{ name }} }}") { +#pragma warning disable CS0618 // Type or member is obsolete PreprocessHttpRequestMessage = callbackTester.Invoke +#pragma warning restore CS0618 // Type or member is obsolete }; var defaultHeaders = StarWarsClient.HttpClient.DefaultRequestHeaders; @@ -222,6 +222,5 @@ query Long { // let the server finish its query chatQuery.LongRunningQueryBlocker.Set(); } - } } diff --git a/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs b/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs index 426df661..00b884d3 100644 --- a/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs +++ b/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs @@ -168,7 +168,6 @@ public class MessageAddedContent } } - [Fact] public async void CanReconnectWithSameObservable() { @@ -234,6 +233,7 @@ public class UserJoinedSubscriptionResult public class UserJoinedContent { public string DisplayName { get; set; } + public string Id { get; set; } } @@ -241,7 +241,6 @@ public class UserJoinedContent private readonly GraphQLRequest _subscriptionRequest2 = new GraphQLRequest(SUBSCRIPTION_QUERY2); - [Fact] public async void CanConnectTwoSubscriptionsSimultaneously() { @@ -376,7 +375,6 @@ public async void CanHandleConnectionTimeout() } } - [Fact] public async void CanHandleSubscriptionError() { @@ -407,8 +405,6 @@ public async void CanHandleSubscriptionError() [Fact] public async void CanHandleQueryErrorInSubscription() { - var test = new GraphQLRequest("tset", new { test = "blaa" }); - var callbackMonitor = ChatClient.ConfigureMonitorForOnWebsocketConnected(); await ChatClient.InitializeWebsocketConnection(); callbackMonitor.Should().HaveBeenInvokedWithPayload(); diff --git a/tests/GraphQL.Integration.Tests/WebsocketTests/Newtonsoft.cs b/tests/GraphQL.Integration.Tests/WebsocketTests/Newtonsoft.cs index aa6cb945..d77ca14c 100644 --- a/tests/GraphQL.Integration.Tests/WebsocketTests/Newtonsoft.cs +++ b/tests/GraphQL.Integration.Tests/WebsocketTests/Newtonsoft.cs @@ -7,6 +7,7 @@ namespace GraphQL.Integration.Tests.WebsocketTests public class Newtonsoft : Base, IClassFixture { public Newtonsoft(ITestOutputHelper output, NewtonsoftIntegrationServerTestFixture fixture) : base(output, fixture) - { } + { + } } } diff --git a/tests/GraphQL.Primitives.Tests/GraphQL.Primitives.Tests.csproj b/tests/GraphQL.Primitives.Tests/GraphQL.Primitives.Tests.csproj index e2f04365..99070b4c 100644 --- a/tests/GraphQL.Primitives.Tests/GraphQL.Primitives.Tests.csproj +++ b/tests/GraphQL.Primitives.Tests/GraphQL.Primitives.Tests.csproj @@ -6,21 +6,8 @@ netcoreapp3.1 - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/tests/GraphQL.Primitives.Tests/GraphQLLocationTest.cs b/tests/GraphQL.Primitives.Tests/GraphQLLocationTest.cs index ce34bcc8..3d7fde8d 100644 --- a/tests/GraphQL.Primitives.Tests/GraphQLLocationTest.cs +++ b/tests/GraphQL.Primitives.Tests/GraphQLLocationTest.cs @@ -2,10 +2,8 @@ namespace GraphQL.Primitives.Tests { - public class GraphQLLocationTest { - [Fact] public void ConstructorFact() { @@ -60,7 +58,5 @@ public void GetHashCodeFact() var graphQLLocation2 = new GraphQLLocation { Column = 1, Line = 2 }; Assert.True(graphQLLocation1.GetHashCode() == graphQLLocation2.GetHashCode()); } - } - } diff --git a/tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs b/tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs index 145ecfa6..e5b41a15 100644 --- a/tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs +++ b/tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs @@ -2,10 +2,8 @@ namespace GraphQL.Primitives.Tests { - public class GraphQLRequestTest { - [Fact] public void ConstructorFact() { @@ -47,7 +45,6 @@ public void Equality3Fact() Assert.Equal(graphQLRequest1, graphQLRequest2); } - [Fact] public void Equality4Fact() { @@ -122,11 +119,10 @@ public void PropertyQueryGetFact() [Fact] public void PropertyQuerySetFact() { - var graphQLRequest = - new GraphQLRequest("{hero{name}}", new {varName = "varValue1"}, "operationName") - { - Query = "{hero{name2}}" - }; + var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName") + { + Query = "{hero{name2}}" + }; Assert.Equal("{hero{name2}}", graphQLRequest.Query); } @@ -147,7 +143,7 @@ public void PropertyOperationNameNullGetFact() [Fact] public void PropertyOperationNameSetFact() { - var graphQLRequest = new GraphQLRequest("{hero{name}}", new {varName = "varValue"}, "operationName1") + var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue" }, "operationName1") { OperationName = "operationName2" }; @@ -171,16 +167,17 @@ public void PropertyVariableNullGetFact() [Fact] public void PropertyVariableSetFact() { - var graphQLRequest = new GraphQLRequest("{hero{name}}", new {varName = "varValue1"}, "operationName1") + var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName1") { - Variables = new {varName = "varValue2"} + Variables = new + { + varName = "varValue2" + } }; Assert.Equal(new { varName = "varValue2" }, graphQLRequest.Variables); } - } - } diff --git a/tests/GraphQL.Primitives.Tests/GraphQLResponseTest.cs b/tests/GraphQL.Primitives.Tests/GraphQLResponseTest.cs index ed23f3fd..ce062e05 100644 --- a/tests/GraphQL.Primitives.Tests/GraphQLResponseTest.cs +++ b/tests/GraphQL.Primitives.Tests/GraphQLResponseTest.cs @@ -2,10 +2,8 @@ namespace GraphQL.Primitives.Tests { - public class GraphQLResponseTest { - [Fact] public void Constructor1Fact() { @@ -112,7 +110,5 @@ public void GetHashCodeFact() }; Assert.True(graphQLResponse1.GetHashCode() == graphQLResponse2.GetHashCode()); } - } - } diff --git a/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs b/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs index da1ccf02..74add0a1 100644 --- a/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs +++ b/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs @@ -7,13 +7,13 @@ namespace GraphQL.Primitives.Tests { public class JsonSerializationTests { - [Fact] public void WebSocketResponseDeserialization() { var testObject = new ExtendedTestObject { Id = "test", OtherData = "this is some other stuff" }; var json = JsonSerializer.Serialize(testObject); var deserialized = JsonSerializer.Deserialize(json); + deserialized.Id.Should().Be("test"); var dict = JsonSerializer.Deserialize>(json); var childObject = (JsonElement)dict["ChildObject"]; childObject.GetProperty("Id").GetString().Should().Be(testObject.ChildObject.Id); @@ -22,7 +22,6 @@ public void WebSocketResponseDeserialization() public class TestObject { public string Id { get; set; } - } public class ExtendedTestObject : TestObject diff --git a/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj b/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj index 8ae5718c..ad08e233 100644 --- a/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj +++ b/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj @@ -1,13 +1,13 @@ - + - - netcoreapp3.1 - + + netcoreapp3.1 + - - - - - + + + + + diff --git a/tests/GraphQL.Server.Test/GraphQL/Models/Repository.cs b/tests/GraphQL.Server.Test/GraphQL/Models/Repository.cs index e387d32b..95e5f1fc 100644 --- a/tests/GraphQL.Server.Test/GraphQL/Models/Repository.cs +++ b/tests/GraphQL.Server.Test/GraphQL/Models/Repository.cs @@ -3,19 +3,21 @@ namespace GraphQL.Server.Test.GraphQL.Models { - public class Repository { public int DatabaseId { get; set; } + public string Id { get; set; } + public string Name { get; set; } + public object Owner { get; set; } + public Uri Url { get; set; } } public class RepositoryGraphType : ObjectGraphType { - public RepositoryGraphType() { Name = nameof(Repository); @@ -25,7 +27,5 @@ public RepositoryGraphType() //this.Field(expression => expression.Owner); Field>("url"); } - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/Storage.cs b/tests/GraphQL.Server.Test/GraphQL/Storage.cs index 613a537a..0280b28f 100644 --- a/tests/GraphQL.Server.Test/GraphQL/Storage.cs +++ b/tests/GraphQL.Server.Test/GraphQL/Storage.cs @@ -5,10 +5,8 @@ namespace GraphQL.Server.Test.GraphQL { - public static class Storage { - public static IQueryable Repositories { get; } = new List() .Append(new Repository { @@ -19,7 +17,5 @@ public static class Storage Url = new Uri("https://github.com/graphql-dotnet/graphql-client") }) .AsQueryable(); - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/TestMutation.cs b/tests/GraphQL.Server.Test/GraphQL/TestMutation.cs index a1077dc6..dfd67981 100644 --- a/tests/GraphQL.Server.Test/GraphQL/TestMutation.cs +++ b/tests/GraphQL.Server.Test/GraphQL/TestMutation.cs @@ -2,14 +2,10 @@ namespace GraphQL.Server.Test.GraphQL { - public class TestMutation : ObjectGraphType { - public TestMutation() { } - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/TestQuery.cs b/tests/GraphQL.Server.Test/GraphQL/TestQuery.cs index 2fb39ab3..bf8aa3ae 100644 --- a/tests/GraphQL.Server.Test/GraphQL/TestQuery.cs +++ b/tests/GraphQL.Server.Test/GraphQL/TestQuery.cs @@ -4,10 +4,8 @@ namespace GraphQL.Server.Test.GraphQL { - public class TestQuery : ObjectGraphType { - public TestQuery() { Field("repository", arguments: new QueryArguments(new QueryArgument> { Name = "owner" }, new QueryArgument> { Name = "name" }), resolve: context => @@ -17,7 +15,5 @@ public TestQuery() return Storage.Repositories.FirstOrDefault(predicate => predicate.Name == name); }); } - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/TestSchema.cs b/tests/GraphQL.Server.Test/GraphQL/TestSchema.cs index a61d3558..c589d388 100644 --- a/tests/GraphQL.Server.Test/GraphQL/TestSchema.cs +++ b/tests/GraphQL.Server.Test/GraphQL/TestSchema.cs @@ -2,17 +2,13 @@ namespace GraphQL.Server.Test.GraphQL { - public class TestSchema : Schema { - public TestSchema() { Query = new TestQuery(); //this.Mutation = new TestMutation(); //this.Subscription = new TestSubscription(); } - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/TestSubscription.cs b/tests/GraphQL.Server.Test/GraphQL/TestSubscription.cs index f6d50470..4fabf386 100644 --- a/tests/GraphQL.Server.Test/GraphQL/TestSubscription.cs +++ b/tests/GraphQL.Server.Test/GraphQL/TestSubscription.cs @@ -2,14 +2,10 @@ namespace GraphQL.Server.Test.GraphQL { - public class TestSubscription : ObjectGraphType { - public TestSubscription() { } - } - } diff --git a/tests/GraphQL.Server.Test/Program.cs b/tests/GraphQL.Server.Test/Program.cs index 2b5c329a..df18d888 100644 --- a/tests/GraphQL.Server.Test/Program.cs +++ b/tests/GraphQL.Server.Test/Program.cs @@ -4,18 +4,14 @@ namespace GraphQL.Server.Test { - public class Program { - public static async Task Main(string[] args) => await CreateHostBuilder(args).Build().RunAsync(); public static IWebHostBuilder CreateHostBuilder(string[] args = null) => WebHost.CreateDefaultBuilder(args) - .UseKestrel(options => { options.AllowSynchronousIO = true; }) + .UseKestrel(options => options.AllowSynchronousIO = true) .UseStartup(); - } - } diff --git a/tests/GraphQL.Server.Test/Startup.cs b/tests/GraphQL.Server.Test/Startup.cs index d330ed5d..a1f710ee 100644 --- a/tests/GraphQL.Server.Test/Startup.cs +++ b/tests/GraphQL.Server.Test/Startup.cs @@ -2,23 +2,13 @@ using GraphQL.Server.Ui.GraphiQL; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace GraphQL.Server.Test { - public class Startup { - - public IConfiguration Configuration { get; } - - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - public void Configure(IApplicationBuilder app) { var webHostEnvironment = app.ApplicationServices.GetRequiredService(); @@ -43,7 +33,5 @@ public void ConfigureServices(IServiceCollection services) options.ExposeExceptions = true; }).AddWebSockets(); } - } - } diff --git a/tests/IntegrationTestServer/IntegrationTestServer.csproj b/tests/IntegrationTestServer/IntegrationTestServer.csproj index a1f28376..da280f0f 100644 --- a/tests/IntegrationTestServer/IntegrationTestServer.csproj +++ b/tests/IntegrationTestServer/IntegrationTestServer.csproj @@ -2,6 +2,7 @@ netcoreapp3.1 + IntegrationTestServer.Program diff --git a/tests/IntegrationTestServer/Startup.cs b/tests/IntegrationTestServer/Startup.cs index 71a76d67..49586dc0 100644 --- a/tests/IntegrationTestServer/Startup.cs +++ b/tests/IntegrationTestServer/Startup.cs @@ -24,16 +24,14 @@ public Startup(IConfiguration configuration, IWebHostEnvironment environment) } public IConfiguration Configuration { get; } + public IWebHostEnvironment Environment { get; } // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - services.Configure(options => - { - options.AllowSynchronousIO = true; - }); + services.Configure(options => options.AllowSynchronousIO = true); services.AddTransient(provider => new FuncDependencyResolver(provider.GetService)); services.AddChatSchema(); diff --git a/tests/tests.props b/tests/tests.props index 46e995fc..19bc6d36 100644 --- a/tests/tests.props +++ b/tests/tests.props @@ -1,17 +1,21 @@ - - + - + false - true - + $(NoWarn);NU1701;IDE1006 + - - - - - + + + + + + all + runtime;build;native;contentfiles;analyzers;buildtransitive + + +