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

Make Azure.Core cspell-clean #21027

Merged
merged 5 commits into from
May 12, 2021
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
44 changes: 41 additions & 3 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.1",
"language": "en_US",
"languageId": "csharp",
"dictionaries": ["powershell"],
"dictionaries": ["powershell", "softwareTerms", "csharp"],
"ignorePaths": [
"**/SessionRecords/**",
"**/packages/**",
Expand All @@ -21,13 +21,51 @@
"*.sha512",
"*.ico",
"*.pri",
"*.trx",
"*.binlog",
"*.log",
"*.sln",
"*.user",
".vscode/cspell.json"
],
// cspell is not case sensitive
// Sort words alphabetically to make this list easier to use
"words": ["azsdk", "pwsh"],
"words": [
"apos",
"azsdk",
"blazor",
"contoso",
"deserializes",
"diagnoser",
"epsg",
"expando",
"finalizer",
"finalizers",
"ints",
"lucene",
"mgmt",
"nunit",
"odata",
"otel",
"overridden",
"parallelization",
"pkcs",
"pwsh",
"referer",
"renormalize",
"retriable",
"structs",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cspell for some reason doesn't pluralize words from the dictionary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pluralization is quite difficult even for a single language. Not surprising. Most don't that I've seen.

"uints",
"unformattable",
"uninstrumented",
"westus",
"xunit"
],
"overrides": [
{ "filename": "**/sdk/formrecognizer/**/*.cs", "words": ["ZhHant"] },
{
"filename": "**/sdk/formrecognizer/**/*.cs",
"words": ["ZhHant"]
},
{
"filename": "**/eng/pipelines/templates/jobs/ci.yml",
"words": ["warnaserror"]
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core.Experimental/src/DynamicContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal DynamicContent(JsonData body)

// TODO(matell): When this moves to Azure.Core, this static method should be exposed from the abstract RequestContent class.
/// <summary>
/// Creates a RequestConent for a given JSON object.
/// Creates a RequestContent for a given JSON object.
/// </summary>
/// <param name="body">The JSON object the request content represents</param>
/// <returns>A RequestContent which is the UTF-8 encoding of the underlying DynamicJson</returns>
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core.Experimental/src/DynamicRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override RequestContent? Content
/// </summary>
public dynamic DynamicBody { get => Body; }

// TODO(matell): In Krzysztof's prototype we also took DiagnosticScope as a parameter, do we still need that?
// TODO(matell): In the prototype we also took DiagnosticScope as a parameter, do we still need that?
/// <summary>
/// Creates an instance of <see cref="RequestContent"/> that wraps <see cref="JsonData"/> content.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public sealed class GeoJsonConverter : JsonConverter<GeoObject>
private const string TypeProperty = "type";
private const string GeometriesProperty = "geometries";
private const string CoordinatesProperty = "coordinates";
// cspell:ignore bbox
private const string BBoxProperty = "bbox";

/// <inheritdoc />
Expand Down
20 changes: 10 additions & 10 deletions sdk/core/Azure.Core.Experimental/src/JsonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ public JsonData SetEmptyArray(string propertyName)
/// <summary>
/// Inserts a new value at the end of an array.
/// </summary>
/// <param name="serializable">The value to insert intot he array.</param>
/// <param name="serializable">The value to insert into the array.</param>
/// <returns>A <see cref="JsonData"/> of the serialized object.</returns>
/// <remarks>
/// If the <see cref="Kind"/> property is not <see cref="JsonValueKind.Array"/> this method throws <see cref="InvalidOperationException"/>.
Expand All @@ -499,7 +499,7 @@ public JsonData Add(object? serializable)
/// <summary>
/// Inserts a new value at the end of an array.
/// </summary>
/// <param name="serializable">The value to insert intot he array.</param>
/// <param name="serializable">The value to insert into the array.</param>
/// <param name="options">Options to control the conversion behavior.</param>
/// <returns>A <see cref="JsonData"/> of the serialized object.</returns>
/// <remarks>
Expand All @@ -515,7 +515,7 @@ public JsonData Add(object? serializable, JsonSerializerOptions options)
/// <summary>
/// Inserts a new value at the end of an array.
/// </summary>
/// <param name="serializable">The value to insert intot he array.</param>
/// <param name="serializable">The value to insert into the array.</param>
/// <returns>A <see cref="JsonData"/> of the serialized object.</returns>
/// <remarks>
/// If the <see cref="Kind"/> property is not <see cref="JsonValueKind.Array"/> this method throws <see cref="InvalidOperationException"/>.
Expand All @@ -530,7 +530,7 @@ public JsonData Add<T>(T[] serializable)
/// <summary>
/// Inserts a new value at the end of an array.
/// </summary>
/// <param name="serializable">The value to insert intot he array.</param>
/// <param name="serializable">The value to insert into the array.</param>
/// <param name="options">Options to control the conversion behavior.</param>
/// <returns>A <see cref="JsonData"/> of the serialized object.</returns>
/// <remarks>
Expand Down Expand Up @@ -589,7 +589,7 @@ public JsonData this[int arrayIndex]
/// Gets or sets a value for a given property in an object.
/// </summary>
/// <param name="propertyName">The name of the property in the object to get or set.</param>
/// <returns>The value for the given proeprty name.</returns>
/// <returns>The value for the given property name.</returns>
/// <remarks>
/// If the <see cref="Kind"/> property is not <see cref="JsonValueKind.Object"/> this method throws <see cref="InvalidOperationException"/>.
/// </remarks>
Expand Down Expand Up @@ -860,7 +860,7 @@ public JsonValueKind Kind
/// <summary>
/// Returns the number of elements in this array.
/// </summary>
/// <remarks>If <see cref="Kind"/> is not <see cref="JsonValueKind.Array"/> this methods thows <see cref="InvalidOperationException"/>.</remarks>
/// <remarks>If <see cref="Kind"/> is not <see cref="JsonValueKind.Array"/> this methods throws <see cref="InvalidOperationException"/>.</remarks>
public int Length
{
get => EnsureArray().Count;
Expand All @@ -869,7 +869,7 @@ public int Length
/// <summary>
/// Returns the names of all the properties of this object.
/// </summary>
/// <remarks>If <see cref="Kind"/> is not <see cref="JsonValueKind.Object"/> this methods thows <see cref="InvalidOperationException"/>.</remarks>
/// <remarks>If <see cref="Kind"/> is not <see cref="JsonValueKind.Object"/> this methods throws <see cref="InvalidOperationException"/>.</remarks>
public IEnumerable<string> Properties
{
get => EnsureObject().Keys;
Expand All @@ -878,7 +878,7 @@ public IEnumerable<string> Properties
/// <summary>
/// Returns all the elements in this array.
/// </summary>
/// <remarks>If<see cref="Kind"/> is not<see cref="JsonValueKind.Array"/> this methods thows <see cref = "InvalidOperationException" />.</remarks>
/// <remarks>If<see cref="Kind"/> is not<see cref="JsonValueKind.Array"/> this methods throws <see cref = "InvalidOperationException" />.</remarks>
public IEnumerable<JsonData> Items
{
get => EnsureArray();
Expand Down Expand Up @@ -1305,8 +1305,8 @@ private IEnumerable<object> BuildMembers()
}

/// <summary>
/// The default searlization behavior for <see cref="JsonData"/> is not the behavior we want, we want to use
/// the underlying JSON value that <see cref="JsonData"/> wraps, instead of using the default beahvior for
/// The default serialization behavior for <see cref="JsonData"/> is not the behavior we want, we want to use
/// the underlying JSON value that <see cref="JsonData"/> wraps, instead of using the default behavior for
/// POCOs.
/// </summary>
private class JsonConverter : JsonConverter<JsonData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Azure.Core
{
/// <summary>
/// A concrete ClientOptions for use by client with no additonal options other than the common ones.
/// A concrete ClientOptions for use by client with no additional options other than the common ones.
/// </summary>
#pragma warning disable AZC0008 // ClientOptions should have a nested enum called ServiceVersion
public class ProtocolClientOptions : ClientOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void CanRoundripPoint()
[Test]
public void CanRoundripBBox()
{
// cspell:ignore bbox
var input = $"{{ \"type\": \"Point\", \"coordinates\": [{PS(0)}], \"bbox\": [ {PS(1)}, {PS(2)} ] }}";

var point = AssertRoundtrip<GeoPoint>(input);
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/Azure.Core.TestFramework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class AppConfigurationTestEnvironment : TestEnvironment
// Argument is the output name in the test-resources.json
public string Endpoint => GetRecordedVariable("APPCONFIGURATION_ENDPOINT");
// Variables retrieved using GetVariable will not be recorded but the method will throw if the variable is not set
public string SystemAssignedVault => GetVariable("IDENTITYTEST_IMDSTEST_SYSTEMASSIGNEDVAULT");
public string SystemAssignedVault => GetVariable("IDENTITYTEST_TEST_SYSTEMASSIGNEDVAULT");
// Variables retrieved using GetOptionalVariable will not be recorded and the method will return null if variable is not set
public string TestPassword => GetOptionalVariable("AZURE_IDENTITY_TEST_PASSWORD") ?? "SANITIZED";
}
Expand Down Expand Up @@ -468,7 +468,7 @@ Some bindings require code on the customized side to access fields that are gene
}
```

For this to work with tests, your test class must have an `InternalsVisisbleTo` in your `AssemblyInfo.cs`:
For this to work with tests, your test class must have an `InternalsVisibleTo` in your `AssemblyInfo.cs`:

```csharp
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core.TestFramework/src/EntryRecordModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Azure.Core.TestFramework
public enum EntryRecordModel
{
Record,
DontRecord,
DoNotRecord,
RecordWithoutRequestBody
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void Intercept(IInvocation invocation)
var type = invocation.Method.ReturnType;

var isAsyncEnumerable = false;
// cspell:ignore iface
foreach (var iface in type.GetInterfaces())
{
if (iface.IsGenericType && iface.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>))
Expand Down Expand Up @@ -79,7 +80,7 @@ internal static void WrapAsyncResult(IInvocation invocation, object target, Meth

internal static void WrapAsyncResultCore<T>(IInvocation invocation, Type genericType, AsyncCallInterceptor<T> wrap)
{
// All this ceremony is not to await the returned Task/ValueTask syncronously
// All this ceremony is not to await the returned Task/ValueTask synchronously
// instead we are replacing the invocation.ReturnValue with the ValidateDiagnosticScope task
// but we need to make sure the types match
if (genericType == typeof(Task<>))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ internal override void InitValues()
}
_switches = info.GetValue(null);
// initialize the switches, which can be null until the first switch is set.
// cspell:disable-next-line
var initSwitch = "azuresdktestinitswitch";
_originalValues[initSwitch] = null;
AppContext.SetSwitch(initSwitch, false);
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public TokenCredential Credential
}

/// <summary>
/// Returns whether environment is ready to use. Should be overriden to provide service specific sampling scenario.
/// Returns whether environment is ready to use. Should be overridden to provide service specific sampling scenario.
/// The test framework will wait until this returns true before starting tests.
/// Use this place to hook up logic that polls if eventual consistency has happened.
///
Expand Down
3 changes: 2 additions & 1 deletion sdk/core/Azure.Core.TestFramework/src/TestRecording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class TestRecording : IDisposable
{
private const string RandomSeedVariableKey = "RandomSeed";
private const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
// cspell: disable-next-line
private const string charsLower = "abcdefghijklmnopqrstuvwxyz0123456789";
internal const string DateTimeOffsetNowVariableKey = "DateTimeOffsetNow";

Expand Down Expand Up @@ -314,7 +315,7 @@ public void DisableIdReuse()

public DisableRecordingScope DisableRecording()
{
return new DisableRecordingScope(this, EntryRecordModel.DontRecord);
return new DisableRecordingScope(this, EntryRecordModel.DoNotRecord);
}

public DisableRecordingScope DisableRequestBodyRecording()
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Explore and install [available Azure SDK libraries](https://azure.github.io/azur

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information see the [Code of Conduct FAQ][code_of_conduct_faq] or contact opencode@microsoft.com with any additional questions or comments.

Expand Down
4 changes: 2 additions & 2 deletions sdk/core/Azure.Core/generate_solution.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $RepoRoot = Resolve-Path $PSScriptRoot\..\..\..
$ObjDirectory = "$RepoRoot\artifacts\obj";
dotnet restore $RepoRoot\eng\service.proj

pushd $PSScriptRoot
Push-Location $PSScriptRoot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While for PS scripts avoiding aliases is recommended, @danieljurek we should probably not be spell-checking the code itself in scripts - doc comments, string literals, public APIs, etc. This seems like an overreach and probably a bit too verbose in most cases.


try
{
Expand Down Expand Up @@ -39,5 +39,5 @@ try
}
finally
{
popd
Pop-Location
}
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/samples/Diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Logging

Azure SDKs produce various log messages that include information about:
1. Requests and reponses
1. Requests and responses
2. Authentication attempts
3. Retries

Expand Down
6 changes: 3 additions & 3 deletions sdk/core/Azure.Core/samples/Pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ options.AddPolicy(new StopwatchPolicy(), HttpPipelinePosition.PerRetry);

## Implementing a policy

To implement a policy create a class deriving from `HttpPipelinePolicy` and overide `ProcessAsync` and `Process` methods. Request can be acessed via `message.Request`. Response is accessible via `message.Response` but only after `ProcessNextAsync`/`ProcessNext` was called.
To implement a policy create a class deriving from `HttpPipelinePolicy` and overide `ProcessAsync` and `Process` methods. Request can be accessed via `message.Request`. Response is accessible via `message.Response` but only after `ProcessNextAsync`/`ProcessNext` was called.

```C# Snippet:StopwatchPolicy
public class StopwatchPolicy : HttpPipelinePolicy
Expand Down Expand Up @@ -51,9 +51,9 @@ public class StopwatchPolicy : HttpPipelinePolicy
}
```

## Implementing a syncronous policy
## Implementing a synchronous policy

If your policy doesn't do any asyncronous operations you can derive from `HttpPipelineSynchronousPolicy` and override `OnSendingRequest` or `OnResponseReceived` method.
If your policy doesn't do any asynchronous operations you can derive from `HttpPipelineSynchronousPolicy` and override `OnSendingRequest` or `OnResponseReceived` method.

```C# Snippet:SyncPolicy
public class CustomRequestPolicy : HttpPipelineSynchronousPolicy
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/Azure.Core/samples/Response.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Most client methods return one of the following types:
- `Response` - an HTTP response
- `Response<T>` - a value and HTTP response
- `Pageable<T>` - a collection of values retrieved in pages
- `AsyncPageable<T>` - a collection of values asyncrounosly retrieved in pages
- `AsyncPageable<T>` - a collection of values asynchronously retrieved in pages
- `*Operation<T>` - a long-running operation see [long running operation samples](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/core/Azure.Core/samples/LongRunningOperations.md)

## Accessing HTTP response propreties
Expand Down Expand Up @@ -129,7 +129,7 @@ await foreach (Page<SecretProperties> page in allSecretProperties.AsPages())

## Iterating over pageable

`Pageable<T>` is a syncronous version of `AsyncPageable<T>`, it can be used with a normal `foreach` loop.
`Pageable<T>` is a synchronous version of `AsyncPageable<T>`, it can be used with a normal `foreach` loop.

```C# Snippet:Pageable
// call a service method, which returns Pageable<T>
Expand Down
1 change: 1 addition & 0 deletions sdk/core/Azure.Core/src/Messaging/CloudEventConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ internal static CloudEvent DeserializeCloudEvent(JsonElement element, bool skipV
}
if (cloudEvent.SpecVersion != "1.0")
{
// cspell:word specverion
if (cloudEvent.SpecVersion == null)
{
throw new ArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async ValueTask ProcessAsyncInner(HttpMessage message, ReadOnlyMemory<HttpPipeli

if (!_hasOnReceivedResponse)
{
// If OnReceivedResponse was not overriden we can avoid creating a state machine and return the task directly
// If OnReceivedResponse was not overridden we can avoid creating a state machine and return the task directly
OnSendingRequest(message);
return ProcessNextAsync(message, pipeline);
}
Expand Down
1 change: 1 addition & 0 deletions sdk/core/Azure.Core/src/Shared/LightweightPkcs8Decoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ internal static string ReadObjectIdentifier(byte[] data, ref int offset)
int max = end + 1;
if (max <= i + 4)
{
// cspell:ignore accum
int accum = 0;
for (idx = i; idx < max; idx++)
{
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/Azure.Core/src/Shared/Multipart/MultipartContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ private static void ValidateBoundary(string boundary)
// Instead validate it ourselves and then quote it.
Argument.AssertNotNullOrWhiteSpace(boundary, nameof(boundary));

// cspell:disable
// RFC 2046 Section 5.1.1
// boundary := 0*69<bchars> bcharsnospace
// bchars := bcharsnospace / " "
// bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" / "_" / "," / "-" / "." / "/" / ":" / "=" / "?"
// cspell:enable
if (boundary.Length > 70)
{
throw new ArgumentOutOfRangeException(nameof(boundary), boundary, $"The field cannot be longer than {70} characters.");
Expand Down
2 changes: 2 additions & 0 deletions sdk/core/Azure.Core/tests/Base64UrlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ public string GenerateRandomString(Random rand, int length)

private static readonly (string, string)[] s_staticValues = new (string, string)[]
{
//cSpell:disable
("foo", "Zm9v"),
("<foo!>", "PGZvbyE-"),
("<foo!?", "PGZvbyE_"),
("<foo!?><<foo?>>", "PGZvbyE_Pjw8Zm9vPz4-"),
("<foo!?><<foo?>>foo", "PGZvbyE_Pjw8Zm9vPz4-Zm9v")
//cSpell:enable
};

[Test]
Expand Down
Loading