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

Improve the formatting of descriptions of Types #1895

Conversation

logiclrd
Copy link
Contributor

This PR adds a new type TypeDescriptionUtility that includes some logic to improve the readability where type names are being included in test output. In particular, LINQ result sets are identified and made human-readable. This functionality was originally written for #1812 but was extracted to its own independent PR -- as such this functionality is initially used directly in DataTableCollection, DataColumnCollection and DataRowCollection assertions. It has also been applied to formatting of the type name in TypeSelectorAssertions. The new functionality is unit-tested, and releases.md has been updated to describe the change.

IMPORTANT

  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by unit tests which follow the Arrange-Act-Assert syntax and the naming conventions such as is used in these tests.
  • If the PR adds a feature or fixes a bug, please update the release notes with a functional description that explains what the change means to consumers of this library, which are published on the website.
  • If the PR changes the public API the changes needs to be included by running AcceptApiChanges.ps1 or AcceptApiChanges.sh.
  • If the PR affects the documentation, please include your changes in this pull request so the documentation will appear on the website.

Updated DataTableCollectionAssertionExtensions.cs, DataColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs to use TypeDescriptionUtility.
Updated TypeSelectorAssertions.cs to use TypeDescriptionUtility.
Updated releases.md to describe the change.
@dennisdoomen
Copy link
Member

I think we discussed converting your solution into an IValueFormatter that knows how to render an instance of Type.

@logiclrd
Copy link
Contributor Author

Oh? But that assumes that any time someone wants to format a Type, they want a verbose human-readable description of it. Is that a safe assumption?

@dennisdoomen
Copy link
Member

I'd love to see what that looks like.

@Corniel
Copy link
Contributor

Corniel commented Jul 15, 2022

Consider adopting this extension method:

So:

typeof(int).ToCSharpString().Should().Be("int");
typeof(int[,,]).ToCSharpString().Should().Be("int[,,]");
typeof(Namespace.MyType).ToCSharpString().Should().Be("Namespace.MyType");
typeof(Dictionary<object, List<int?>>[])).ToCSharpString().Should().Be("Dictionary<object, List<int?>>[])");

// etc...

See the specs.

@dennisdoomen
Copy link
Member

Closing because of a lack of progress

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.

None yet

3 participants