Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Documentation (or, is this project dead?) #75

@JasonBock

Description

@JasonBock

I've been playing around with this package, and while I think it has some merit and potential, it feels woefully under-documented, and its advice is confusing.

For example, I ran across an interpolated string in my code where the analyzer raised HAA0601. The help link does nothing, nor is there any code fix available, so I really don't know how to fix this. I'm guessing it's because the value types I have in the string will get boxed? So I created a small benchmark project:

using BenchmarkDotNet.Attributes;

namespace TestFormatting
{
	[MemoryDiagnoser]
	public class FormattingAndBoxing
	{
		private readonly uint value1 = 324;
		private readonly int value2 = 43219;

		[Benchmark]
		public int FormatStringWithNoToString() =>
			$"The expected call count is incorrect. Expected: {this.value1}, received: {this.value2}.".Length;

		[Benchmark]
		public int FormatStringWithToString() =>
			$"The expected call count is incorrect. Expected: {this.value1.ToString()}, received: {this.value2.ToString()}.".Length;
	}
}

The results were....interesting:

|                     Method |     Mean |    Error |   StdDev |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|--------------------------- |---------:|---------:|---------:|-------:|------:|------:|----------:|
| FormatStringWithNoToString | 400.7 ns | 4.240 ns | 3.759 ns | 0.0496 |     - |     - |     208 B |
|   FormatStringWithToString | 118.4 ns | 1.277 ns | 1.132 ns | 0.0687 |     - |     - |     288 B |

So the second way is faster, but it actually allocates a bit more memory? Is this correct? If so, how do I really address this analyzer's diagnostic? Or is my test faulty?

It's really down to prescriptive advice. This package needs far better documentation for it to be useful on every-day projects. I'd love to use it and continue to provide feedback, but it's unclear if this is even being maintained anymore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions