Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply dotnet-format and fix typos #264

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ Your interface methods may return one of the following types:

- `Task`: This method does not return any data, but the task will complete when the request has completed
- `Task<T>` (where `T` is not one of the types listed below): This method will deserialize the response into an object of type `T`, using Json.NET (or a custom deserializer, see [Controlling Serialization and Deserialization below](#controlling-serialization-and-deserialization)).
- `Task<string>`: This method returns the raw response, as a string (although this can be customised, [see here]((#deserializing-responses-responsedeserializer))).
- `Task<HttpResponseMessage>`: This method returns the raw [`HttpResponseMessage`](https://docs.microsoft.com/en-gb/dotnet/api/system.net.http.httpresponsemessage) resulting from the request. It does not do any deserialiation. You must dispose this object after use.
- `Task<Response<T>>`: This method returns a `Response<T>`. A `Response<T>` contains both the deserialied response (of type `T`), but also the `HttpResponseMessage`. Use this when you want to have both the deserialized response, and access to things like the response headers. You must dispose this object after use.
- `Task<string>`: This method returns the raw response, as a string (although this can be customized, [see here]((#deserializing-responses-responsedeserializer))).
- `Task<HttpResponseMessage>`: This method returns the raw [`HttpResponseMessage`](https://docs.microsoft.com/en-gb/dotnet/api/system.net.http.httpresponsemessage) resulting from the request. It does not do any deserialization. You must dispose this object after use.
- `Task<Response<T>>`: This method returns a `Response<T>`. A `Response<T>` contains both the deserialized response (of type `T`), but also the `HttpResponseMessage`. Use this when you want to have both the deserialized response, and access to things like the response headers. You must dispose this object after use.
- `Task<Stream>`: This method returns a Stream containing the response. Use this to e.g. download a file and stream it to disk. You must dispose this object after use.

Non-async methods are not supported (use `.Wait()` or `.Result` as appropriate if you do want to make your request synchronous).
Expand Down Expand Up @@ -852,7 +852,7 @@ else
Cancelling Requests
-------------------

If you want to be able to cancel a request, pass a `CancellationToken` as one of the method paramters.
If you want to be able to cancel a request, pass a `CancellationToken` as one of the method parameters.

```csharp
public interface ISomeApi
Expand Down Expand Up @@ -888,7 +888,7 @@ public interface IGitHubApi

### Variable Interface Headers

If you want to have a header that applies to every single request, and whose value is variable, then use a variable interface header. These are specifed using properties, using a `[Header("Name")]` attribute on that property.
If you want to have a header that applies to every single request, and whose value is variable, then use a variable interface header. These are specified using properties, using a `[Header("Name")]` attribute on that property.

For example:

Expand Down Expand Up @@ -1877,7 +1877,7 @@ Yes. It is safe to create implementations of interfaces from multiple threads at

### I want to upload a file

Let's assume you want to upload a file (from a stream), setting its name and content-type manually (skip these bits of not). There are a couple of ways of doing this, depending on your needs:
Let's assume you want to upload a file (from a stream), setting its name and content-type manually (skip these bits if not). There are a couple of ways of doing this, depending on your needs:

```csharp
public interface ISomeApi
Expand Down
6 changes: 3 additions & 3 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ csharp_style_unused_value_assignment_preference = discard_variable:silent
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion

# Miscellanious preferences
# Miscellaneous preferences
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_using_directive_placement = outside_namespace:warning
Expand Down Expand Up @@ -122,7 +122,7 @@ csharp_new_line_between_query_expression_clauses = true
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current
csharp_indent_block_contents = true
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = false

Expand Down Expand Up @@ -236,4 +236,4 @@ dotnet_naming_rule.type_parameters_must_begin_with_t.severity = warning

dotnet_diagnostic.CA1816.severity = none
dotnet_diagnostic.IDE0079.severity = none # Seems to be mis-firing all the time
dotnet_diagnostic.IDE0057.severity = none # Can't use Range, as targetting things that don't define it
dotnet_diagnostic.IDE0057.severity = none # Can't use Range, as targeting things that don't define it
2 changes: 1 addition & 1 deletion src/Common/AllowAnyStatusCodeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public AllowAnyStatusCodeAttribute()
}

/// <summary>
/// Initialises a new instance of the <see cref="AllowAnyStatusCodeAttribute"/> classe whi
/// Initialises a new instance of the <see cref="AllowAnyStatusCodeAttribute"/>.
/// </summary>
/// <param name="allowAnyStatusCode">True to allow any response status code; False to throw an exception on response status codes that do not indicate success</param>
public AllowAnyStatusCodeAttribute(bool allowAnyStatusCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void ReportQueryMapParameterIsNotADictionary(MethodModel method, Paramete
{
throw new ImplementationCreationException(
DiagnosticCode.QueryMapParameterIsNotADictionary,
$"Method '{method.MethodInfo.Name}': [QueryMap] parameter is not of type IDictionary or IDictionary<TKey, TValue> (or one of their descendents)");
$"Method '{method.MethodInfo.Name}': [QueryMap] parameter is not of type IDictionary or IDictionary<TKey, TValue> (or one of their descendants)");
}

public void ReportHeaderParameterMustNotHaveValue(MethodModel method, ParameterModel parameter)
Expand Down
16 changes: 8 additions & 8 deletions src/Common/Implementation/Emission/DiagnosticReporter.Roslyn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void ReportPropertyMustBeReadWrite(PropertyModel property)
private static readonly DiagnosticDescriptor requesterPropertyMustHaveZeroAttributes = CreateDescriptor(
DiagnosticCode.RequesterPropertyMustHaveZeroAttributes,
"IRequester properties must not have any attributes",
"IRequester property must not have any attribtues");
"IRequester property must not have any attributes");
public void ReportRequesterPropertyMustHaveZeroAttributes(PropertyModel propertyModel, List<AttributeModel> attributes)
{
this.AddDiagnostic(
Expand Down Expand Up @@ -276,7 +276,7 @@ public void ReportMultipleHttpRequestMessageParametersForKey(MethodModel _, stri

private static readonly DiagnosticDescriptor parameterMustNotBeByRef = CreateDescriptor(
DiagnosticCode.ParameterMustNotBeByRef,
"Method parameters must not not be ref, in or out",
"Method parameters must not be ref, in or out",
"Method parameter '{0}' must not be ref, in or out");
public void ReportParameterMustNotBeByRef(MethodModel _, ParameterModel parameter)
{
Expand Down Expand Up @@ -317,7 +317,7 @@ public void ReportMultipleBodyParameters(MethodModel _, IEnumerable<ParameterMod
private static readonly DiagnosticDescriptor queryMapParameterIsNotADictionary = CreateDescriptor(
DiagnosticCode.QueryMapParameterIsNotADictionary,
"QueryMap parameters must be dictionaries",
"[QueryMap] parameter is not of the type IDictionary or IDictionary<TKey, TValue> (or their descendents)");
"[QueryMap] parameter is not of the type IDictionary or IDictionary<TKey, TValue> (or their descendants)");
public void ReportQueryMapParameterIsNotADictionary(MethodModel _, ParameterModel parameter)
{
this.AddDiagnostic(queryMapParameterIsNotADictionary, SymbolLocations(parameter.ParameterSymbol));
Expand Down Expand Up @@ -400,7 +400,7 @@ public void ReportCouldNotFindRestEaseType(string metadataName)

private static readonly DiagnosticDescriptor couldNotFindSystemType = CreateDescriptor(
DiagnosticCode.CouldNotFindSystemType,
"Unable to find System type type",
"Unable to find System type",
"Unable to find System type '{0}'. Make sure you are referencing the appropriate assembly");
public void ReportCouldNotFindSystemType(string metadataName)
{
Expand All @@ -419,8 +419,8 @@ public void ReportExpressionsNotAvailable()

private static readonly DiagnosticDescriptor attributeConstructorNotRecognised = CreateDescriptor(
DiagnosticCode.AttributeConstructorNotRecognised,
"Attribute constructor not recognised",
"Constructor for attribute type '{0}' not recongised. This attribute will be ignored. Make sure you're referencing an up-to-date version of RestEase",
"Attribute constructor not recognized",
"Constructor for attribute type '{0}' not recognized. This attribute will be ignored. Make sure you're referencing an up-to-date version of RestEase",
DiagnosticSeverity.Warning);
public void ReportAttributeConstructorNotRecognised(AttributeData attributeData, ISymbol declaringSymbol)
{
Expand All @@ -432,8 +432,8 @@ public void ReportAttributeConstructorNotRecognised(AttributeData attributeData,

private static readonly DiagnosticDescriptor attributePropertyNotRecognised = CreateDescriptor(
DiagnosticCode.AttributePropertyNotRecognised,
"Attribute property not recognised",
"Property '{0} for attribute type '{1}' not recongised. This property will be ignored. Make sure you're referencing an up-to-date version of RestEase",
"Attribute property not recognized",
"Property '{0} for attribute type '{1}' not recognized. This property will be ignored. Make sure you're referencing an up-to-date version of RestEase",
DiagnosticSeverity.Warning);
public void ReportAttributePropertyNotRecognised(AttributeData attributeData, KeyValuePair<string, TypedConstant> namedArgument, ISymbol declaringSymbol)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Implementation/Emission/EmittedProperty.Emit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace RestEase.Implementation.Emission
internal partial class EmittedProperty
{
public FieldBuilder FieldBuilder { get; }

public EmittedProperty(PropertyModel propertyModel, FieldBuilder fieldBuilder)
{
this.PropertyModel = propertyModel;
Expand Down
6 changes: 3 additions & 3 deletions src/Common/Implementation/Emission/TypeEmitter.Emit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public EmittedProperty EmitProperty(PropertyModel propertyModel)
public void EmitRequesterProperty(PropertyModel propertyModel)
{
MethodAttributes attributes = MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.SpecialName;

var propertyBuilder = this.typeBuilder.DefineProperty(propertyModel.PropertyInfo.Name, PropertyAttributes.None, propertyModel.PropertyInfo.PropertyType, null);
var getter = this.typeBuilder.DefineMethod(propertyModel.PropertyInfo.GetMethod!.Name, attributes, propertyModel.PropertyInfo.PropertyType, ArrayUtil.Empty<Type>());
var getterIlGenerator = getter.GetILGenerator();
Expand All @@ -178,15 +178,15 @@ public void EmitDisposeMethod(MethodModel methodModel)
methodModel.Parameters.Select(x => x.ParameterInfo.ParameterType).ToArray());
this.typeBuilder.DefineMethodOverride(methodBuilder, methodModel.MethodInfo);
var ilGenerator = methodBuilder.GetILGenerator();

ilGenerator.Emit(OpCodes.Ldarg_0);
ilGenerator.Emit(OpCodes.Ldfld, this.requesterField);
ilGenerator.Emit(OpCodes.Callvirt, MethodInfos.IDisposable_Dispose);
ilGenerator.Emit(OpCodes.Ret);
}

public MethodEmitter EmitMethod(MethodModel methodModel)
{
{
var methodEmitter = new MethodEmitter(this.typeBuilder, methodModel, this.numMethods, this.requesterField, this.classHeadersField);
this.numMethods++;
return methodEmitter;
Expand Down
16 changes: 8 additions & 8 deletions src/Common/NullableAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sealed class NotNullAttribute : Attribute
#endif
sealed class MaybeNullWhenAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified return value condition.</summary>
/// <summary>Initialises the attribute with the specified return value condition.</summary>
/// <param name="returnValue">
/// The return value condition. If the method returns this value, the associated parameter may be null.
/// </param>
Expand All @@ -78,7 +78,7 @@ sealed class MaybeNullWhenAttribute : Attribute
#endif
sealed class NotNullWhenAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified return value condition.</summary>
/// <summary>Initialises the attribute with the specified return value condition.</summary>
/// <param name="returnValue">
/// The return value condition. If the method returns this value, the associated parameter will not be null.
/// </param>
Expand All @@ -97,7 +97,7 @@ sealed class NotNullWhenAttribute : Attribute
#endif
sealed class NotNullIfNotNullAttribute : Attribute
{
/// <summary>Initializes the attribute with the associated parameter name.</summary>
/// <summary>Initialises the attribute with the associated parameter name.</summary>
/// <param name="parameterName">
/// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null.
/// </param>
Expand Down Expand Up @@ -126,7 +126,7 @@ sealed class DoesNotReturnAttribute : Attribute
#endif
sealed class DoesNotReturnIfAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified parameter value.</summary>
/// <summary>Initialises the attribute with the specified parameter value.</summary>
/// <param name="parameterValue">
/// The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to
/// the associated parameter matches this value.
Expand All @@ -150,13 +150,13 @@ sealed class DoesNotReturnIfAttribute : Attribute
#endif
sealed class MemberNotNullAttribute : Attribute
{
/// <summary>Initializes the attribute with a field or property member.</summary>
/// <summary>Initialises the attribute with a field or property member.</summary>
/// <param name="member">
/// The field or property member that is promised to be not-null.
/// </param>
public MemberNotNullAttribute(string member) => Members = new[] { member };

/// <summary>Initializes the attribute with the list of field and property members.</summary>
/// <summary>Initialises the attribute with the list of field and property members.</summary>
/// <param name="members">
/// The list of field and property members that are promised to be not-null.
/// </param>
Expand All @@ -175,7 +175,7 @@ sealed class MemberNotNullAttribute : Attribute
#endif
sealed class MemberNotNullWhenAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified return value condition and a field or property member.</summary>
/// <summary>Initialises the attribute with the specified return value condition and a field or property member.</summary>
/// <param name="returnValue">
/// The return value condition. If the method returns this value, the associated parameter will not be null.
/// </param>
Expand All @@ -188,7 +188,7 @@ public MemberNotNullWhenAttribute(bool returnValue, string member)
Members = new[] { member };
}

/// <summary>Initializes the attribute with the specified return value condition and list of field and property members.</summary>
/// <summary>Initialises the attribute with the specified return value condition and list of field and property members.</summary>
/// <param name="returnValue">
/// The return value condition. If the method returns this value, the associated parameter will not be null.
/// </param>
Expand Down
2 changes: 1 addition & 1 deletion src/Common/PathAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public PathAttribute()
}

/// <summary>
/// Initializes a new instance of the <see cref="PathAttribute"/> class, with the given serialization method
/// Initialises a new instance of the <see cref="PathAttribute"/> class, with the given serialization method
/// </summary>
/// <param name="serializationMethod">Serialization method to use to serialize the value</param>
public PathAttribute(PathSerializationMethod serializationMethod)
Expand Down
4 changes: 2 additions & 2 deletions src/Common/RequestAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public sealed class PutAttribute : RequestAttributeBase
public PutAttribute() : base(HttpMethod.Put) { }

/// <summary>
/// Initialises a new instance of the <see cref="PutAttribute"/> class, with the given relativ epath
/// Initialises a new instance of the <see cref="PutAttribute"/> class, with the given relative path
/// </summary>
/// <param name="path">Relative path to use</param>
public PutAttribute(string path) : base(HttpMethod.Put, path) { }
Expand Down Expand Up @@ -205,7 +205,7 @@ public sealed class PatchAttribute : RequestAttributeBase
public PatchAttribute() : base(PatchMethod) { }

/// <summary>
/// Initialises a new instance of the <see cref="PatchAttribute"/> class, with the given relativ epath
/// Initialises a new instance of the <see cref="PatchAttribute"/> class, with the given relative path
/// </summary>
/// <param name="path">Relative path to use</param>
public PatchAttribute(string path) : base(PatchMethod, path) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using RestEase.HttpClientFactory;
using Moq;
using System.Net.Http;
using Moq.Protected;
using System.Threading;
using RestEase.HttpClientFactory;
using Xunit;

namespace RestEase.UnitTests.HttpClientFactoryTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<readme>README.md</readme>
<icon>icon.png</icon>
<projectUrl>https://github.com/canton7/RestEase</projectUrl>
<description>HttpClientFactory adapter for ASP.NET Core for RestEase: the easy-to-use typesafe REST API client library, which is simple and customisable.</description>
<description>HttpClientFactory adapter for ASP.NET Core for RestEase: the easy-to-use typesafe REST API client library, which is simple and customizable.</description>
<copyright>Copyright © Antony Male 2015-2022</copyright>
<tags>REST JSON RestEase SourceGenerator</tags>
<repository type="git" url="https://github.com/canton7/RestEase" />
Expand Down
Loading