Take the following class, without [PublicAPI]
attribute, ReSharper says that all public members can be made private.
using System;
using JetBrains.Annotations;
namespace ObjMtl
{
// [PublicAPI]
[NoReorder]
public sealed class WavefrontMaterialColor
{
public float R;
public float B;
public float G;
public float A = 1.0f;
public float this[int index]
{
get => GetComponent(index);
set => GetComponent(index) = value;
}
private ref float GetComponent(int index)
{
switch (index)
{
case 0: return ref R;
case 1: return ref G;
case 2: return ref B;
case 3: return ref A;
default: throw new ArgumentOutOfRangeException(nameof(index));
}
}
}
}
This is nice but it's double-edged, while it filters the ambient noise from ReSharper, when adding it you also lose the overview of what could be hidden that may be an implementation detail. So, I used to add it quite often but then realized that it wasn't a good move since you hide many suggestions that may be worth applying later.
You could, instead of adding it to the class itself, add it to each members individually, but most of the time I found myself adding it to all members which is quite verbose to say the least. The only advantage in doing so is that should you add a member to the class, it won't immediately be seen as public because of the class-level attribute.
Now I'm on the other side, I'm considering not adding it all, but then you get tons of worthless suggestions, I guess you get the point...
Question:
What are some good metrics in deciding when a member should be declared part of the public API?