-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Make System.Formats.Nrbf public #103232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Make System.Formats.Nrbf public #103232
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8a396bb
apply the new library name: System.Formats.Nrbf
adamsitnik b49c824
rename the types and methods, make them public:
adamsitnik 8ed896f
introduce non-generic PrimitiveTypeRecord, use it where it simplifies…
adamsitnik 380b82e
remove ClassRecord.GetArrayOfPrimitiveType, add GetArrayRecord
adamsitnik 0edfa3c
introduce SerializationRecordId, use it
adamsitnik f205fa9
make BinaryArrayType internal, add ArrayRecord.IsJagged, remove suppo…
adamsitnik 43336ed
fix the build
adamsitnik e703c6b
TypeName matching changes:
adamsitnik 7bd4b27
rename RecordType to SerializationRecordType, remove the byte size co…
adamsitnik a171648
add ref project
adamsitnik cd54d66
fix the build
adamsitnik daa7431
remove the need of having a separate stack of ids that are being pars…
adamsitnik dedcf0c
Apply suggestions from code review
adamsitnik e0ad582
remove special casing of TimeSpan that seems to be missing [TypeForwa…
adamsitnik 0664932
type name matching: take generic type definition into account
adamsitnik 3673b4f
Apply suggestions from code review
adamsitnik 7352704
address code review feedback
adamsitnik 5c3b266
Merge remote-tracking branch 'upstream/main' into nrbfPublic
adamsitnik 9fbf59c
try to solve the pre-built error about System.ValueTuple by removing …
adamsitnik 39832eb
increase the margin of error (this test needs to ensure 2GB is not be…
adamsitnik a151e6e
Apply suggestions from code review
adamsitnik 729a61f
Apply suggestions from code review
adamsitnik 770761d
add missing xml docs
adamsitnik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// ------------------------------------------------------------------------------ | ||
// Changes to this file must follow the https://aka.ms/api-review process. | ||
// ------------------------------------------------------------------------------ | ||
|
||
namespace System.Formats.Nrbf | ||
{ | ||
public abstract partial class ArrayRecord : System.Formats.Nrbf.SerializationRecord | ||
{ | ||
internal ArrayRecord() { } | ||
public override System.Formats.Nrbf.SerializationRecordId Id { get { throw null; } } | ||
public abstract System.ReadOnlySpan<int> Lengths { get; } | ||
public int Rank { get { throw null; } } | ||
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The code for an array of the specified type might not be available.")] | ||
public System.Array GetArray(System.Type expectedArrayType, bool allowNulls = true) { throw null; } | ||
} | ||
public abstract partial class ClassRecord : System.Formats.Nrbf.SerializationRecord | ||
{ | ||
internal ClassRecord() { } | ||
public override System.Formats.Nrbf.SerializationRecordId Id { get { throw null; } } | ||
public System.Collections.Generic.IEnumerable<string> MemberNames { get { throw null; } } | ||
public override System.Reflection.Metadata.TypeName TypeName { get { throw null; } } | ||
public System.Formats.Nrbf.ArrayRecord? GetArrayRecord(string memberName) { throw null; } | ||
public bool GetBoolean(string memberName) { throw null; } | ||
public byte GetByte(string memberName) { throw null; } | ||
public char GetChar(string memberName) { throw null; } | ||
public System.Formats.Nrbf.ClassRecord? GetClassRecord(string memberName) { throw null; } | ||
public System.DateTime GetDateTime(string memberName) { throw null; } | ||
public decimal GetDecimal(string memberName) { throw null; } | ||
public double GetDouble(string memberName) { throw null; } | ||
public short GetInt16(string memberName) { throw null; } | ||
public int GetInt32(string memberName) { throw null; } | ||
public long GetInt64(string memberName) { throw null; } | ||
public object? GetRawValue(string memberName) { throw null; } | ||
public sbyte GetSByte(string memberName) { throw null; } | ||
public System.Formats.Nrbf.SerializationRecord? GetSerializationRecord(string memberName) { throw null; } | ||
public float GetSingle(string memberName) { throw null; } | ||
public string? GetString(string memberName) { throw null; } | ||
public System.TimeSpan GetTimeSpan(string memberName) { throw null; } | ||
public ushort GetUInt16(string memberName) { throw null; } | ||
public uint GetUInt32(string memberName) { throw null; } | ||
public ulong GetUInt64(string memberName) { throw null; } | ||
public bool HasMember(string memberName) { throw null; } | ||
} | ||
public static partial class NrbfDecoder | ||
{ | ||
public static System.Formats.Nrbf.SerializationRecord Decode(System.IO.Stream payload, out System.Collections.Generic.IReadOnlyDictionary<System.Formats.Nrbf.SerializationRecordId, System.Formats.Nrbf.SerializationRecord> recordMap, System.Formats.Nrbf.PayloadOptions options=null, bool leaveOpen=false) { throw null; } | ||
public static System.Formats.Nrbf.SerializationRecord Decode(System.IO.Stream payload, System.Formats.Nrbf.PayloadOptions? options=null, bool leaveOpen=false) { throw null; } | ||
public static System.Formats.Nrbf.ClassRecord DecodeClassRecord(System.IO.Stream payload, System.Formats.Nrbf.PayloadOptions? options=null, bool leaveOpen=false) { throw null; } | ||
public static bool StartsWithPayloadHeader(byte[] bytes) { throw null; } | ||
public static bool StartsWithPayloadHeader(System.IO.Stream stream) { throw null; } | ||
} | ||
public sealed partial class PayloadOptions | ||
{ | ||
public PayloadOptions() { } | ||
public System.Reflection.Metadata.TypeNameParseOptions? TypeNameParseOptions { get { throw null; } set { } } | ||
public bool UndoTruncatedTypeNames { get { throw null; } set { } } | ||
} | ||
public abstract partial class PrimitiveTypeRecord : System.Formats.Nrbf.SerializationRecord | ||
{ | ||
internal PrimitiveTypeRecord() { } | ||
public object Value { get { throw null; } } | ||
} | ||
public abstract partial class PrimitiveTypeRecord<T> : System.Formats.Nrbf.PrimitiveTypeRecord | ||
{ | ||
internal PrimitiveTypeRecord() { } | ||
public override System.Reflection.Metadata.TypeName TypeName { get { throw null; } } | ||
public new T Value { get { throw null; } } | ||
} | ||
public abstract partial class SerializationRecord | ||
{ | ||
internal SerializationRecord() { } | ||
public abstract System.Formats.Nrbf.SerializationRecordId Id { get; } | ||
public abstract System.Formats.Nrbf.SerializationRecordType RecordType { get; } | ||
public abstract System.Reflection.Metadata.TypeName TypeName { get; } | ||
public bool TypeNameMatches(System.Type type) { throw null; } | ||
} | ||
public partial struct SerializationRecordId : System.IEquatable<System.Formats.Nrbf.SerializationRecordId> | ||
{ | ||
public bool Equals(System.Formats.Nrbf.SerializationRecordId other) { throw null; } | ||
public override bool Equals(object? obj) { throw null; } | ||
public override int GetHashCode() { throw null; } | ||
} | ||
public enum SerializationRecordType | ||
{ | ||
SerializedStreamHeader = 0, | ||
ClassWithId = 1, | ||
SystemClassWithMembers = 2, | ||
ClassWithMembers = 3, | ||
SystemClassWithMembersAndTypes = 4, | ||
ClassWithMembersAndTypes = 5, | ||
BinaryObjectString = 6, | ||
BinaryArray = 7, | ||
MemberPrimitiveTyped = 8, | ||
MemberReference = 9, | ||
ObjectNull = 10, | ||
MessageEnd = 11, | ||
BinaryLibrary = 12, | ||
ObjectNullMultiple256 = 13, | ||
ObjectNullMultiple = 14, | ||
ArraySinglePrimitive = 15, | ||
ArraySingleObject = 16, | ||
ArraySingleString = 17, | ||
MethodCall = 21, | ||
MethodReturn = 22, | ||
} | ||
public abstract partial class SZArrayRecord<T> : System.Formats.Nrbf.ArrayRecord | ||
{ | ||
internal SZArrayRecord() { } | ||
public int Length { get { throw null; } } | ||
public override System.ReadOnlySpan<int> Lengths { get { throw null; } } | ||
public abstract T?[] GetArray(bool allowNulls = true); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks> | ||
<CLSCompliant>false</CLSCompliant> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="System.Formats.Nrbf.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(LibrariesProjectRoot)System.IO.Hashing\ref\System.IO.Hashing.csproj" /> | ||
<ProjectReference Include="$(LibrariesProjectRoot)System.Reflection.Metadata\ref\System.Reflection.Metadata.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'"> | ||
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresDynamicCodeAttribute.cs" /> | ||
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" /> | ||
</ItemGroup> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/AllowedRecordType.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace System.Formats.Nrbf; | ||
|
||
[Flags] | ||
internal enum AllowedRecordTypes : uint | ||
{ | ||
None = 0, | ||
SerializedStreamHeader = 1 << SerializationRecordType.SerializedStreamHeader, | ||
ClassWithId = 1 << SerializationRecordType.ClassWithId, | ||
SystemClassWithMembersAndTypes = 1 << SerializationRecordType.SystemClassWithMembersAndTypes, | ||
ClassWithMembersAndTypes = 1 << SerializationRecordType.ClassWithMembersAndTypes, | ||
BinaryObjectString = 1 << SerializationRecordType.BinaryObjectString, | ||
BinaryArray = 1 << SerializationRecordType.BinaryArray, | ||
MemberPrimitiveTyped = 1 << SerializationRecordType.MemberPrimitiveTyped, | ||
MemberReference = 1 << SerializationRecordType.MemberReference, | ||
ObjectNull = 1 << SerializationRecordType.ObjectNull, | ||
MessageEnd = 1 << SerializationRecordType.MessageEnd, | ||
BinaryLibrary = 1 << SerializationRecordType.BinaryLibrary, | ||
ObjectNullMultiple256 = 1 << SerializationRecordType.ObjectNullMultiple256, | ||
ObjectNullMultiple = 1 << SerializationRecordType.ObjectNullMultiple, | ||
ArraySinglePrimitive = 1 << SerializationRecordType.ArraySinglePrimitive, | ||
ArraySingleObject = 1 << SerializationRecordType.ArraySingleObject, | ||
ArraySingleString = 1 << SerializationRecordType.ArraySingleString, | ||
|
||
Nulls = ObjectNull | ObjectNullMultiple256 | ObjectNullMultiple, | ||
|
||
/// <summary> | ||
/// Any .NET object (a primitive, a reference type, a reference or single null). | ||
/// </summary> | ||
AnyObject = MemberPrimitiveTyped | ||
| ArraySingleObject | ArraySinglePrimitive | ArraySingleString | BinaryArray | ||
| ClassWithId | ClassWithMembersAndTypes | SystemClassWithMembersAndTypes | ||
| BinaryObjectString | ||
| MemberReference | ||
| ObjectNull, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.