Skip to content

Conversation

@schaabs
Copy link
Contributor

@schaabs schaabs commented Sep 9, 2019

  • APIs on CertificateClient implemented
  • Model type serialization implemented
  • Initial CertificateClient Live / Recorded Tests

@schaabs schaabs requested a review from heaths September 9, 2019 15:38

public static readonly Action EmailContacts = new Action(EmailContactsValue);

public override bool Equals(object obj)
Copy link
Member

Choose a reason for hiding this comment

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

May as well implement IEquitable<Action> which provides facilities to a lot of other uses (like hashing, comparison, etc.) without the boxing for object.Equals. Then just implement this as:

public override bool Equals(object obj) => obj is Action action && Equals(action);


public override int GetHashCode()
{
return base.GetHashCode();
Copy link
Member

Choose a reason for hiding this comment

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

Given the _value here is really the crux of the enum-like structs, should we instead return _value?.GetHashCode() ?? 0 instead?


public override string ToString()
{
return _value;
Copy link
Member

Choose a reason for hiding this comment

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

Could be null, and ToString() should never return null or empty: https://docs.microsoft.com/en-us/dotnet/api/system.object.tostring?view=netframework-4.8#notes-to-inheritors. Perhaps we should not allow either into the constructor to avoid this possibility.

return _value;
}

public static bool operator ==(Action a, Action b) => a.Equals(b);
Copy link
Member

Choose a reason for hiding this comment

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

This would box the Action. See comment above about implementing IEquitable<Action> to avoid this.


namespace Azure.Security.KeyVault.Certificates
{
public class AdministratorDetails
Copy link
Member

Choose a reason for hiding this comment

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

Should this be implementing IJsonSerializable and IJsonDeserializable?

Properties = pollResponse;
}

if (Properties.Status == "completed")
Copy link
Member

Choose a reason for hiding this comment

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

Nit: we define "magic numbers" (err, strings) elsewhere throughout code. May as well here.

}
private void ParseId(string id)
{
var idToParse = new Uri(id, UriKind.Absolute); ;
Copy link
Member

Choose a reason for hiding this comment

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

I, too, love var but seems our coding style is to use explicit type names. 😢

private const string CancellationRequestedPropertyName = "cancellation_requested";
private static readonly JsonEncodedText CancellationRequestedPropertyNameBytes = JsonEncodedText.Encode(CancellationRequestedPropertyName);

private bool _cancellationRequested;
Copy link
Member

Choose a reason for hiding this comment

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

Could be readonly.

Upn
}

//public enum CertificateContentType
Copy link
Member

Choose a reason for hiding this comment

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

Guessing this should just be deleted.


namespace Azure.Security.KeyVault.Certificates.Tests
{
public class CertificatesTestBase : RecordedTestBase
Copy link
Member

Choose a reason for hiding this comment

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

Should probably be abstract.

internal const string AutoRenewValue = "AutoRenew";
internal const string EmailContactsValue = "EmailContacts";

public Action(string Action)
Copy link
Member

Choose a reason for hiding this comment

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

Should be lowercase "action". Also, for consistency, do we want all these values throughout structs like this to just be "value"?

@schaabs
Copy link
Contributor Author

schaabs commented Sep 10, 2019

/azp run net - keyvault - ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

return obj is CertificateContentType && string.CompareOrdinal(_value, ((CertificateContentType)obj)._value) == 0;
}

public override int GetHashCode()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why have an override that doesn't do anything?

Copy link
Member

Choose a reason for hiding this comment

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

Compiler warning if you don't.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then we should have a real implementation because we can do a better (faster) job than the default implementation.

@schaabs schaabs merged commit 399d6c2 into Azure:master Sep 10, 2019
/// </summary>
public static readonly CertificateContentType Pem = new CertificateContentType("application/x-pem");

public override bool Equals(object obj)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a non-boxing equality operator

/// <summary>
/// Supported JsonWebKey key types (kty)
/// </summary>
public struct CertificateKeyType
Copy link
Contributor

Choose a reason for hiding this comment

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

readonly

JoshLove-msft pushed a commit to JoshLove-msft/azure-sdk-for-net that referenced this pull request Sep 10, 2019
* Azure.Security.KeyVault.Certificates initial implementation

* adding test recordings

* Fixing faux enums Equals and GetHashCode

* squash incomplete xml comments

* adding xml doc comments

* updating keyvault release notes

* removing duplicate refernce to shared source file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants