SBK0100: Removed API

Analyzer SnowBank.Core
Severity Error
Code fix Yes

Message

'{0}' was removed in version 7. {1}

{0} is the removed name, {1} the replacement from the table below.

Why

Version 7 renamed three Slice factories. The compiler reports the missing member (CS0117, or CS7036 for Create, whose name survives as Create<TState>(int, TState, SpanAction)) without saying what replaced it. This rule reports at the same place, names the replacement, and offers a code fix.

Removed name Replacement Code fix
Slice.Create(bytes) Slice.Copy(bytes) or Slice.FromBytes(span) Yes, for an array argument
Slice.Create(size) new SliceWriter(size) for a buffer No
Slice.FromSpan(span) Slice.FromBytes(span) Yes
Slice.FromAscii(text) Slice.FromStringAscii(text) Yes

Bad

Slice M(byte[] bytes) => Slice.Create(bytes);

Good

Slice M(byte[] bytes) => Slice.Copy(bytes);

Code fix

The fix renames Create to Copy (when the argument is an array), FromSpan to FromBytes, and FromAscii to FromStringAscii.

Suppress

#pragma warning disable SBK0100 // reason

or, for a whole project, in .editorconfig:

dotnet_diagnostic.SBK0100.severity = none