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

Style checking for core #7516

Merged
merged 1 commit into from
Sep 9, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ root = true
# Default settings:
# A newline ending every file
# Use 4 spaces as indentation
[*]
[sdk/*/Azure.*/**]
insert_final_newline = true
indent_style = space
indent_size = 4

# C# files
[*.cs]
[sdk/*/Azure.*/**.cs]
# New line preferences
csharp_new_line_before_open_brace = all # vs-default: any
csharp_new_line_before_else = true # vs-default: true
Expand Down
133 changes: 0 additions & 133 deletions sdk/core/Azure.Core/.editorconfig

This file was deleted.

4 changes: 0 additions & 4 deletions sdk/core/Azure.Core/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Disables StyleCopAnalyzer, Remove this property to enable it -->
<PropertyGroup>
<EnableStyleCopAnalyzers>false</EnableStyleCopAnalyzers>
</PropertyGroup>
<!--
Add any shared properties you want for the projects under this package directory that need to be set before the auto imported Directory.Build.props
-->
Expand Down
30 changes: 20 additions & 10 deletions sdk/core/Azure.Core/src/Buffers/StreamMemoryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ internal static class AzureBaseBuffersExtensions
{
public static async Task WriteAsync(this Stream stream, ReadOnlyMemory<byte> buffer, CancellationToken cancellation = default)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
if (stream == null)
throw new ArgumentNullException(nameof(stream));

if (buffer.Length == 0) return;
chidozieononiwu marked this conversation as resolved.
Show resolved Hide resolved
if (buffer.Length == 0)
return;
byte[]? array = null;
try
{
Expand All @@ -28,25 +30,30 @@ public static async Task WriteAsync(this Stream stream, ReadOnlyMemory<byte> buf
{
if (array == null || buffer.Length < buffer.Length)
{
if (array != null) ArrayPool<byte>.Shared.Return(array);
if (array != null)
ArrayPool<byte>.Shared.Return(array);
array = ArrayPool<byte>.Shared.Rent(buffer.Length);
}
if (!buffer.TryCopyTo(array)) throw new Exception("could not rent large enough buffer.");
if (!buffer.TryCopyTo(array))
throw new Exception("could not rent large enough buffer.");
await stream.WriteAsync(array, 0, buffer.Length, cancellation).ConfigureAwait(false);
}

}
finally
{
if (array != null) ArrayPool<byte>.Shared.Return(array);
if (array != null)
ArrayPool<byte>.Shared.Return(array);
}
}

public static async Task WriteAsync(this Stream stream, ReadOnlySequence<byte> buffer, CancellationToken cancellation = default)
{
if (stream == null) throw new ArgumentNullException(nameof(stream));
if (stream == null)
throw new ArgumentNullException(nameof(stream));

if (buffer.Length == 0) return;
if (buffer.Length == 0)
return;
byte[]? array = null;
try
{
Expand All @@ -60,17 +67,20 @@ public static async Task WriteAsync(this Stream stream, ReadOnlySequence<byte> b
{
if (array == null || buffer.Length < segment.Length)
{
if (array != null) ArrayPool<byte>.Shared.Return(array);
if (array != null)
ArrayPool<byte>.Shared.Return(array);
array = ArrayPool<byte>.Shared.Rent(segment.Length);
}
if (!segment.TryCopyTo(array)) throw new Exception("could not rent large enough buffer.");
if (!segment.TryCopyTo(array))
throw new Exception("could not rent large enough buffer.");
await stream.WriteAsync(array, 0, segment.Length, cancellation).ConfigureAwait(false);
}
}
}
finally
{
if (array != null) ArrayPool<byte>.Shared.Return(array);
if (array != null)
ArrayPool<byte>.Shared.Return(array);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Azure.Core.Extensions
{

public interface IAzureClientFactoryBuilderWithConfiguration<in TConfiguration>: IAzureClientFactoryBuilder
public interface IAzureClientFactoryBuilderWithConfiguration<in TConfiguration> : IAzureClientFactoryBuilder
{
IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(TConfiguration configuration) where TOptions : class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace Azure.Core.Extensions
{
public interface IAzureClientFactoryBuilderWithCredential
{
IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(Func<TOptions, TokenCredential, TClient> clientFactory, bool requiresCredential = true) where TOptions: class;
IAzureClientBuilder<TClient, TOptions> RegisterClientFactory<TClient, TOptions>(Func<TOptions, TokenCredential, TClient> clientFactory, bool requiresCredential = true) where TOptions : class;
}
}
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/src/FailedResponseException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class RequestFailedException : Exception

public RequestFailedException(int status, string message)
: this(status, message, null)
{}
{ }

public RequestFailedException(int status, string message, Exception? innerException)
: base(message, innerException)
Expand Down
10 changes: 5 additions & 5 deletions sdk/core/Azure.Core/src/Http/HttpClientTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ internal static IEnumerable<HttpHeader> GetHeaders(HttpHeaders headers, HttpCont
internal static bool RemoveHeader(HttpHeaders headers, HttpContent? content, string name)
{
// .Remove throws on invalid header name so use TryGet here to check
if (headers.TryGetValues(name, out _ ) && headers.Remove(name))
if (headers.TryGetValues(name, out _) && headers.Remove(name))
{
return true;
}

return content?.Headers.TryGetValues(name, out _ ) == true && content.Headers.Remove(name);
return content?.Headers.TryGetValues(name, out _) == true && content.Headers.Remove(name);
}

internal static bool ContainsHeader(HttpHeaders headers, HttpContent? content, string name)
Expand Down Expand Up @@ -145,7 +145,7 @@ private static string JoinHeaderValues(IEnumerable<string> values)
return string.Join(",", values);
}

sealed class PipelineRequest : Request
private sealed class PipelineRequest : Request
{
private bool _wasSent = false;
private readonly HttpRequestMessage _requestMessage;
Expand Down Expand Up @@ -294,7 +294,7 @@ private PipelineContentAdapter EnsureContentInitialized()
return _requestContent;
}

sealed class PipelineContentAdapter : HttpContent
private sealed class PipelineContentAdapter : HttpContent
{
public HttpPipelineRequestContent? PipelineContent { get; set; }

Expand All @@ -315,7 +315,7 @@ protected override bool TryComputeLength(out long length)
}
}

sealed class PipelineResponse : Response
private sealed class PipelineResponse : Response
{
private readonly HttpResponseMessage _responseMessage;

Expand Down
6 changes: 3 additions & 3 deletions sdk/core/Azure.Core/src/Http/HttpHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public static class Common
#pragma warning restore CA1034 // Nested types should not be visible
#pragma warning restore CA1724 // Type name conflicts with standard namespace
{
const string ApplicationJson = "application/json";
const string ApplicationOctetStream = "application/octet-stream";
const string ApplicationFormUrlEncoded = "application/x-www-form-urlencoded";
private const string ApplicationJson = "application/json";
private const string ApplicationOctetStream = "application/octet-stream";
private const string ApplicationFormUrlEncoded = "application/x-www-form-urlencoded";

public static readonly HttpHeader JsonContentType = new HttpHeader(Names.ContentType, ApplicationJson);
public static readonly HttpHeader JsonAccept = new HttpHeader(Names.Accept, ApplicationJson);
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/src/Http/RequestHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Azure.Core.Http
{
public readonly struct RequestHeaders: IEnumerable<HttpHeader>
public readonly struct RequestHeaders : IEnumerable<HttpHeader>
{
private readonly Request _request;

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/src/Http/ResponseHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Azure.Core.Http
{
public readonly struct ResponseHeaders: IEnumerable<HttpHeader>
public readonly struct ResponseHeaders : IEnumerable<HttpHeader>
{
private readonly Response _response;

Expand Down
10 changes: 6 additions & 4 deletions sdk/core/Azure.Core/src/OperationOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace Azure
/// <typeparam name="T">The final result of the LRO.</typeparam>
public abstract class Operation<T> where T : notnull
{
T _value;
Response _response;
private T _value;
private Response _response;

/// <summary>
/// Creates a new instance of the Operation representing the specified
Expand All @@ -43,9 +43,11 @@ protected Operation(string id)
/// </remarks>
public T Value
{
get {
get
{
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
if (!HasValue) throw new InvalidOperationException("operation has not completed");
if (!HasValue)
throw new InvalidOperationException("operation has not completed");
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
return _value;
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/src/Pipeline/AzureOperationScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Azure.Core.Pipeline
{
public readonly struct DiagnosticScope: IDisposable
public readonly struct DiagnosticScope : IDisposable
{
private readonly Activity? _activity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Azure.Core.Pipeline
{
public class BearerTokenAuthenticationPolicy: HttpPipelinePolicy
public class BearerTokenAuthenticationPolicy : HttpPipelinePolicy
{
private readonly TokenCredential _credential;

Expand All @@ -19,7 +19,7 @@ public class BearerTokenAuthenticationPolicy: HttpPipelinePolicy

private DateTimeOffset _refreshOn;

public BearerTokenAuthenticationPolicy(TokenCredential credential, string scope) : this(credential, new []{ scope })
public BearerTokenAuthenticationPolicy(TokenCredential credential, string scope) : this(credential, new[] { scope })
{
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/src/Pipeline/BufferResponsePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Azure.Core.Pipeline
{
internal class BufferResponsePolicy: HttpPipelinePolicy
internal class BufferResponsePolicy : HttpPipelinePolicy
{
protected BufferResponsePolicy()
{
Expand Down
Loading