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 all value types in options classes nullable #1298

Merged
merged 1 commit into from
Sep 26, 2018

Conversation

ob-stripe
Copy link
Contributor

r? @remi-stripe
cc @stripe/api-libraries

  • Add a test to ensure that all value types in options classes are nullable.
    (The test only runs under .NET Core 1.1 and not .NET Framework because reflection works differently, but that's okay: this is a "wholesome" test that enforces a code constraint, not a typical test that verifies the library works as expected under all runtimes.)

  • Actually make all value types in options classes nullable.

@ob-stripe ob-stripe force-pushed the ob-nullable-value-types branch from 330bfaa to 3f8f512 Compare September 26, 2018 14:09
@ob-stripe ob-stripe mentioned this pull request Sep 26, 2018
32 tasks
@remi-stripe remi-stripe self-assigned this Sep 26, 2018
Copy link
Contributor

@remi-stripe remi-stripe left a comment

Choose a reason for hiding this comment

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

Mostly ready to merge but a few minor comments

@@ -8,10 +8,10 @@ public class CardholderListOptions : ListOptions
public DateFilter Created { get; set; }

[JsonProperty("email")]
public int Email { get; set; }
public string Email { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

😱 So many errors in those PRs I submitted :(

BoolNullable = true,
},
want = "?bool=False&bool_nullable=True&decimal=0&enum=test_one&int=0"
want = "?bool=True"
Copy link
Contributor

Choose a reason for hiding this comment

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

Those tests now make a lot more sense, yay!

public class NullableValueTypes
{
[Fact]
public void EnsureAllValueTypesAreNullable()
Copy link
Contributor

Choose a reason for hiding this comment

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

Damn that is a really neat test. Reflection is really cool/powerful!

List<string> results = new List<string>();

// Get all classes that implement INestedOptions
var type = typeof(INestedOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be BaseOptions too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BaseOptions actually implements INestedOptions -- I changed this in #1276. We should probably rename INestedOptions to e.g. IOptions since it now simply indicates that a class contains request parameters, regardless of whether the parameters are nested or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I did miss that. Renaming would definitely make sense though I wonder if having an Interface for nested options is a good way to separate top-level options versus others

// Sort results alphabetically
results = results.OrderBy(i => i).ToList();

// Display our own error message (because Assert.Empty sucks)
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to remove (or reword) that last bit :)

Console.WriteLine($"- {item}");
}

Console.ResetColor();
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a lot of trouble with coloration and such instead of just dumping a list of properties. No strong feels though and I'm sure it looks neat, but wondering if it's too much work/how supported it is

@ob-stripe ob-stripe force-pushed the ob-nullable-value-types branch from 3f8f512 to 4e5486f Compare September 26, 2018 15:40
@ob-stripe
Copy link
Contributor Author

Made the requested changes, ptal @remi-stripe

@remi-stripe remi-stripe assigned ob-stripe and unassigned remi-stripe Sep 26, 2018
@ob-stripe ob-stripe merged commit e02ecda into integration-next-major-version Sep 26, 2018
@ob-stripe ob-stripe deleted the ob-nullable-value-types branch September 26, 2018 16:09
@ob-stripe ob-stripe mentioned this pull request Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants