Skip to content

Commit

Permalink
Convert to file-scoped namespaces, no code changes (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r authored Jul 21, 2022
1 parent 04112cd commit 758ede0
Show file tree
Hide file tree
Showing 108 changed files with 4,511 additions and 4,616 deletions.
17 changes: 10 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ insert_final_newline = false

# Code files
[*.{cs,vb}]

# .NET code style settings - "This." and "Me." qualifiers
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-language-conventions?view=vs-2019#this-and-me
dotnet_style_qualification_for_field = false:warning
Expand Down Expand Up @@ -194,22 +194,25 @@ csharp_space_between_square_brackets = false
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false

# C# formatting settings - Namespace options
csharp_style_namespace_declarations = file_scoped:suggestion

########## name all private fields using camelCase with underscore prefix ##########
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions?view=vs-2019
# dotnet_naming_rule.<namingRuleTitle>.symbols = <symbolTitle>
dotnet_naming_rule.private_fields_with_underscore.symbols = private_fields

# dotnet_naming_symbols.<symbolTitle>.<property> = <value>
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

# dotnet_naming_rule.<namingRuleTitle>.style = <styleTitle>
dotnet_naming_rule.private_fields_with_underscore.style = prefix_underscore

# dotnet_naming_style.<styleTitle>.<property> = <value>
dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _

# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
dotnet_naming_rule.private_fields_with_underscore.severity = warning

Expand Down Expand Up @@ -248,8 +251,8 @@ dotnet_naming_rule.async_methods_end_in_async.style = end_in_async_style

# dotnet_naming_style.<styleTitle>.<property> = <value>
dotnet_naming_style.end_in_async_style.capitalization = pascal_case
dotnet_naming_style.end_in_async_style.word_separator =
dotnet_naming_style.end_in_async_style.required_prefix =
dotnet_naming_style.end_in_async_style.word_separator =
dotnet_naming_style.end_in_async_style.required_prefix =
dotnet_naming_style.end_in_async_style.required_suffix = Async

# dotnet_naming_rule.<namingRuleTitle>.severity = <value>
Expand Down
27 changes: 13 additions & 14 deletions examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
using System.Collections.Generic;

namespace GraphQL.Client.Example
namespace GraphQL.Client.Example;

public class PersonAndFilmsResponse
{
public class PersonAndFilmsResponse
public PersonContent Person { get; set; }

public class PersonContent
{
public PersonContent Person { get; set; }
public string Name { get; set; }

public class PersonContent
{
public string Name { get; set; }
public FilmConnectionContent FilmConnection { get; set; }

public FilmConnectionContent FilmConnection { get; set; }
public class FilmConnectionContent
{
public List<FilmContent> Films { get; set; }

public class FilmConnectionContent
public class FilmContent
{
public List<FilmContent> Films { get; set; }

public class FilmContent
{
public string Title { get; set; }
}
public string Title { get; set; }
}
}
}
Expand Down
49 changes: 24 additions & 25 deletions examples/GraphQL.Client.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
using GraphQL.Client.Http;
using GraphQL.Client.Serializer.Newtonsoft;

namespace GraphQL.Client.Example
namespace GraphQL.Client.Example;

public static class Program
{
public static class Program
public static async Task Main()
{
public static async Task Main()
{
using var graphQLClient = new GraphQLHttpClient("https://swapi.apis.guru/", new NewtonsoftJsonSerializer());
using var graphQLClient = new GraphQLHttpClient("https://swapi.apis.guru/", new NewtonsoftJsonSerializer());

var personAndFilmsRequest = new GraphQLRequest
{
Query = @"
var personAndFilmsRequest = new GraphQLRequest
{
Query = @"
query PersonAndFilms($id: ID) {
person(id: $id) {
name
Expand All @@ -26,25 +26,24 @@ query PersonAndFilms($id: ID) {
}
}
}",
OperationName = "PersonAndFilms",
Variables = new
{
id = "cGVvcGxlOjE="
}
};
OperationName = "PersonAndFilms",
Variables = new
{
id = "cGVvcGxlOjE="
}
};

var graphQLResponse = await graphQLClient.SendQueryAsync<PersonAndFilmsResponse>(personAndFilmsRequest);
Console.WriteLine("raw response:");
Console.WriteLine(JsonSerializer.Serialize(graphQLResponse, new JsonSerializerOptions { WriteIndented = true }));
var graphQLResponse = await graphQLClient.SendQueryAsync<PersonAndFilmsResponse>(personAndFilmsRequest);
Console.WriteLine("raw response:");
Console.WriteLine(JsonSerializer.Serialize(graphQLResponse, new JsonSerializerOptions { WriteIndented = true }));

Console.WriteLine();
Console.WriteLine($"Name: {graphQLResponse.Data.Person.Name}");
var films = string.Join(", ", graphQLResponse.Data.Person.FilmConnection.Films.Select(f => f.Title));
Console.WriteLine($"Films: {films}");
Console.WriteLine();
Console.WriteLine($"Name: {graphQLResponse.Data.Person.Name}");
var films = string.Join(", ", graphQLResponse.Data.Person.FilmConnection.Films.Select(f => f.Title));
Console.WriteLine($"Films: {films}");

Console.WriteLine();
Console.WriteLine("Press any key to quit...");
Console.ReadKey();
}
Console.WriteLine();
Console.WriteLine("Press any key to quit...");
Console.ReadKey();
}
}
Original file line number Diff line number Diff line change
@@ -1,87 +1,86 @@
namespace GraphQL.Client.Abstractions.Websocket
namespace GraphQL.Client.Abstractions.Websocket;

public static class GraphQLWebSocketMessageType
{
public static class GraphQLWebSocketMessageType
{

/// <summary>
/// Client sends this message after plain websocket connection to start the communication with the server
/// The server will response only with GQL_CONNECTION_ACK + GQL_CONNECTION_KEEP_ALIVE(if used) or GQL_CONNECTION_ERROR
/// to this message.
/// payload: Object : optional parameters that the client specifies in connectionParams
/// </summary>
public const string GQL_CONNECTION_INIT = "connection_init";
/// <summary>
/// Client sends this message after plain websocket connection to start the communication with the server
/// The server will response only with GQL_CONNECTION_ACK + GQL_CONNECTION_KEEP_ALIVE(if used) or GQL_CONNECTION_ERROR
/// to this message.
/// payload: Object : optional parameters that the client specifies in connectionParams
/// </summary>
public const string GQL_CONNECTION_INIT = "connection_init";

/// <summary>
/// The server may responses with this message to the GQL_CONNECTION_INIT from client, indicates the server accepted
/// the connection.
/// </summary>
public const string GQL_CONNECTION_ACK = "connection_ack"; // Server -> Client
/// <summary>
/// The server may responses with this message to the GQL_CONNECTION_INIT from client, indicates the server accepted
/// the connection.
/// </summary>
public const string GQL_CONNECTION_ACK = "connection_ack"; // Server -> Client

/// <summary>
/// The server may responses with this message to the GQL_CONNECTION_INIT from client, indicates the server rejected
/// the connection.
/// It server also respond with this message in case of a parsing errors of the message (which does not disconnect the
/// client, just ignore the message).
/// payload: Object: the server side error
/// </summary>
public const string GQL_CONNECTION_ERROR = "connection_error"; // Server -> Client
/// <summary>
/// The server may responses with this message to the GQL_CONNECTION_INIT from client, indicates the server rejected
/// the connection.
/// It server also respond with this message in case of a parsing errors of the message (which does not disconnect the
/// client, just ignore the message).
/// payload: Object: the server side error
/// </summary>
public const string GQL_CONNECTION_ERROR = "connection_error"; // Server -> Client

/// <summary>
/// Server message that should be sent right after each GQL_CONNECTION_ACK processed and then periodically to keep the
/// client connection alive.
/// The client starts to consider the keep alive message only upon the first received keep alive message from the
/// server.
/// <remarks>
/// NOTE: This one here don't follow the standard due to connection optimization
/// </remarks>
/// </summary>
public const string GQL_CONNECTION_KEEP_ALIVE = "ka"; // Server -> Client
/// <summary>
/// Server message that should be sent right after each GQL_CONNECTION_ACK processed and then periodically to keep the
/// client connection alive.
/// The client starts to consider the keep alive message only upon the first received keep alive message from the
/// server.
/// <remarks>
/// NOTE: This one here don't follow the standard due to connection optimization
/// </remarks>
/// </summary>
public const string GQL_CONNECTION_KEEP_ALIVE = "ka"; // Server -> Client

/// <summary>
/// Client sends this message to terminate the connection.
/// </summary>
public const string GQL_CONNECTION_TERMINATE = "connection_terminate"; // Client -> Server
/// <summary>
/// Client sends this message to terminate the connection.
/// </summary>
public const string GQL_CONNECTION_TERMINATE = "connection_terminate"; // Client -> Server

/// <summary>
/// Client sends this message to execute GraphQL operation
/// id: string : The id of the GraphQL operation to start
/// payload: Object:
/// query: string : GraphQL operation as string or parsed GraphQL document node
/// variables?: Object : Object with GraphQL variables
/// operationName?: string : GraphQL operation name
/// </summary>
public const string GQL_START = "start";
/// <summary>
/// Client sends this message to execute GraphQL operation
/// id: string : The id of the GraphQL operation to start
/// payload: Object:
/// query: string : GraphQL operation as string or parsed GraphQL document node
/// variables?: Object : Object with GraphQL variables
/// operationName?: string : GraphQL operation name
/// </summary>
public const string GQL_START = "start";

/// <summary>
/// The server sends this message to transfer the GraphQL execution result from the server to the client, this message
/// is a response for GQL_START message.
/// For each GraphQL operation send with GQL_START, the server will respond with at least one GQL_DATA message.
/// id: string : ID of the operation that was successfully set up
/// payload: Object :
/// data: any: Execution result
/// errors?: Error[] : Array of resolvers errors
/// </summary>
public const string GQL_DATA = "data"; // Server -> Client
/// <summary>
/// The server sends this message to transfer the GraphQL execution result from the server to the client, this message
/// is a response for GQL_START message.
/// For each GraphQL operation send with GQL_START, the server will respond with at least one GQL_DATA message.
/// id: string : ID of the operation that was successfully set up
/// payload: Object :
/// data: any: Execution result
/// errors?: Error[] : Array of resolvers errors
/// </summary>
public const string GQL_DATA = "data"; // Server -> Client

/// <summary>
/// Server sends this message upon a failing operation, before the GraphQL execution, usually due to GraphQL validation
/// errors (resolver errors are part of GQL_DATA message, and will be added as errors array)
/// payload: Error : payload with the error attributed to the operation failing on the server
/// id: string : operation ID of the operation that failed on the server
/// </summary>
public const string GQL_ERROR = "error"; // Server -> Client
/// <summary>
/// Server sends this message upon a failing operation, before the GraphQL execution, usually due to GraphQL validation
/// errors (resolver errors are part of GQL_DATA message, and will be added as errors array)
/// payload: Error : payload with the error attributed to the operation failing on the server
/// id: string : operation ID of the operation that failed on the server
/// </summary>
public const string GQL_ERROR = "error"; // Server -> Client

/// <summary>
/// Server sends this message to indicate that a GraphQL operation is done, and no more data will arrive for the
/// specific operation.
/// id: string : operation ID of the operation that completed
/// </summary>
public const string GQL_COMPLETE = "complete"; // Server -> Client
/// <summary>
/// Server sends this message to indicate that a GraphQL operation is done, and no more data will arrive for the
/// specific operation.
/// id: string : operation ID of the operation that completed
/// </summary>
public const string GQL_COMPLETE = "complete"; // Server -> Client

/// <summary>
/// Client sends this message in order to stop a running GraphQL operation execution (for example: unsubscribe)
/// id: string : operation id
/// </summary>
public const string GQL_STOP = "stop"; // Client -> Server
}
/// <summary>
/// Client sends this message in order to stop a running GraphQL operation execution (for example: unsubscribe)
/// id: string : operation id
/// </summary>
public const string GQL_STOP = "stop"; // Client -> Server
}
Loading

0 comments on commit 758ede0

Please sign in to comment.