Skip to content

Conversation

@YegorStepanov
Copy link
Contributor

@YegorStepanov YegorStepanov commented Sep 24, 2022

Null value is ok, but it is shown as unknown.

It's impossible to get Unknown value now, but I decided to add handling for this situation.

public class ParameterInstance : IDisposable
{
public const string NullParameterTextRepresentation = "?";
public const string NullParameterTextRepresentation = "Null";
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about "<null>"? Makes it more obvious that it's actual null and not the string value "Null".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It better to make it in lowercase Null -> null.

<null>

I like any option except ?.
Although the string value still can be \<null\>.
In addition, we can use a different color for special values (only suitable for the console output)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Although the string value still can be \<null\>.

I don't think it needs to be escaped. The XML serializer will automatically escape those to &lt; &gt;. Unless we don't want those escaped in XML, then maybe (null) instead.

Copy link
Contributor Author

@YegorStepanov YegorStepanov Nov 11, 2022

Choose a reason for hiding this comment

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

Sorry, github markdown doesn't like <> characters and removes them if they are not escaped. I forgot to remove escaping when I added the single quotes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks a little odd to me.

    Method | ParamProperty |     Mean |   Error |  StdDev |
---------- |-------------- |---------:|--------:|--------:|
 Benchmark |        <null> | 102.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |         False | 202.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |          True | 302.0 ns | 6.09 ns | 1.58 ns | ^

    Method | ParamProperty |     Mean |   Error |  StdDev |
---------- |-------------- |---------:|--------:|--------:|
 Benchmark |        <null> | 102.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |             A | 202.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |             B | 302.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |             C | 402.0 ns | 6.09 ns | 1.58 ns | ^

    Method | ParamProperty |     Mean |   Error |  StdDev |
---------- |-------------- |---------:|--------:|--------:|
 Benchmark |        <null> | 102.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |             0 | 202.0 ns | 6.09 ns | 1.58 ns | ^

Copy link
Collaborator

@timcassell timcassell Nov 22, 2022

Choose a reason for hiding this comment

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

I think it looks good. But I guess that's just a matter of preference.

[Edit] But I think I like (null) better.

    Method | ParamProperty |     Mean |   Error |  StdDev |
---------- |-------------- |---------:|--------:|--------:|
 Benchmark |        (null) | 102.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |         False | 202.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |          True | 302.0 ns | 6.09 ns | 1.58 ns | ^

    Method | ParamProperty |     Mean |   Error |  StdDev |
---------- |-------------- |---------:|--------:|--------:|
 Benchmark |        (null) | 102.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |             A | 202.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |             B | 302.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |             C | 402.0 ns | 6.09 ns | 1.58 ns | ^

    Method | ParamProperty |     Mean |   Error |  StdDev |
---------- |-------------- |---------:|--------:|--------:|
 Benchmark |        (null) | 102.0 ns | 6.09 ns | 1.58 ns | ^
 Benchmark |             0 | 202.0 ns | 6.09 ns | 1.58 ns | ^

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.

BenchmarkDotNet doesn't display null parameter correctly

2 participants