Skip to content

Generate reference assembly of System.Memory,4.5.1 with the Roslyn-based GenAPI #11767

@andriipatsula

Description

@andriipatsula

Context

Base issue: #11225
Reference package path: System.Memory
Roslyn-based GenAPI location: https://github.com/dotnet/sdk/tree/main/src/GenAPI/

Usage:

/repos/source-build-reference-packages]# ./generate.sh --pkg microsoft.extensions.logging,2.1.1 --genapi-backend roslyn --dest /repos/source-build-reference-packages/src/referencePackages/roslyn/

Steps:

  1. Generate SBRP package using SBRP generator with the roslyn-based backend
  2. Compare cci-based <-> roslyn-based reference assemblies
  3. Build the SBRP generated with the roslyn-based backend
  4. Collect issues, their occurrence, create bugs for each.
  5. Run the sdk/ApiCompat tool to compare generated API with original

How to compile project in SBRP

Use a docker or a VM and from root folder of source-build-reference-packages run:

/repos/source-build-reference-packages]# ./build.sh --projects ./build.sh --projects /repos/source-build-reference-packages/src/referencePackages/roslyn/system.memory/4.5.1/System.Memory.4.5.1.csproj

How to use the ApiCompat tool

sdk\artifacts\bin\Microsoft.DotNet.ApiCompat.Tool\Debug\net6.0> .\Microsoft.DotNet.ApiCompat.Tool.exe --strict-mode true --enable-rule-attributes-must-match true --enable-rule-cannot-change-parameter-name true --lref ... --rref ... -l ... -r ...

Found Issues:

Occurrence: 40+

Occurrence: 11

Occurrence: 7

Occurrence: 5

+ public readonly partial struct Memory<T>
- public partial struct Memory<T>

Occurrence: 7+
The CCi-based output has ref T, Roslyn-based not

+ public ref T GetPinnableReference() { throw null; }
- public T GetPinnableReference() { throw null; }
+ public ref readonly T this[int index] { get { throw null; } }
- public T this[int index] { get { throw null; } }

Occurrence: 1
error CS0504: The constant 'MaxPrecision' cannot be marked static

+ public const byte MaxPrecision = (byte)99;
- public static const byte MaxPrecision = 99;
/// error CS0535: 'MemoryManager<T>' does not implement interface member 'IDisposable.Dispose()'
///     expects `void IDisposable.Dispose() { }`
public abstract partial class MemoryManager<T> : IMemoryOwner<T>, IDisposable, IPinnable
{
/// ...
        protected abstract void Dispose(bool disposing);
        public abstract Span<T> GetSpan();
/// ...
}

Occurrence: 5+

Occurrence: 3

public abstract partial class ReadOnlySequenceSegment<T>
{
/// ...
+     public System.ReadOnlyMemory<T> Memory { get { throw null; } protected set { } }
-     public System.ReadOnlyMemory<T> Memory { get { throw null; } set { } }
/// ...
}

Metadata

Metadata

Assignees

Labels

area-product-constructionIssues owned by the Product Construction team. Used to label epics and untriaged, loose issues.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions