-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use PayloadReader in System.Resources.Extensions (#102379)
--------- Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Jeremy Barton <jbarton@microsoft.com>
- Loading branch information
1 parent
3073a03
commit 82aba82
Showing
160 changed files
with
16,615 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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
22 changes: 22 additions & 0 deletions
22
...ensions/src/System/Resources/Extensions/BinaryFormat/BinaryFormattedObject.IParseState.cs
This file contains 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,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Runtime.Serialization.BinaryFormat; | ||
|
||
namespace System.Resources.Extensions.BinaryFormat; | ||
|
||
internal sealed partial class BinaryFormattedObject | ||
{ | ||
/// <summary> | ||
/// Parsing state. | ||
/// </summary> | ||
internal interface IParseState | ||
{ | ||
BinaryReader Reader { get; } | ||
IReadOnlyDictionary<int, SerializationRecord> RecordMap { get; } | ||
Options Options { get; } | ||
ITypeResolver TypeResolver { get; } | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...sions/src/System/Resources/Extensions/BinaryFormat/BinaryFormattedObject.ITypeResolver.cs
This file contains 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,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reflection.Metadata; | ||
|
||
namespace System.Resources.Extensions.BinaryFormat; | ||
|
||
internal sealed partial class BinaryFormattedObject | ||
{ | ||
/// <summary> | ||
/// Resolver for types. | ||
/// </summary> | ||
internal interface ITypeResolver | ||
{ | ||
/// <summary> | ||
/// Resolves the given type name against the specified library. | ||
/// </summary> | ||
[RequiresUnreferencedCode("Calls System.Reflection.Assembly.GetType(String)")] | ||
[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] | ||
Type GetType(TypeName typeName); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
....Extensions/src/System/Resources/Extensions/BinaryFormat/BinaryFormattedObject.Options.cs
This file contains 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,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Runtime.Serialization; | ||
using System.Runtime.Serialization.Formatters; | ||
|
||
namespace System.Resources.Extensions.BinaryFormat; | ||
|
||
#pragma warning disable SYSLIB0050 // Type or member is obsolete | ||
|
||
internal sealed partial class BinaryFormattedObject | ||
{ | ||
internal sealed class Options | ||
{ | ||
/// <summary> | ||
/// How exactly assembly names need to match for deserialization. | ||
/// </summary> | ||
public FormatterAssemblyStyle AssemblyMatching { get; set; } = FormatterAssemblyStyle.Simple; | ||
|
||
/// <summary> | ||
/// Type name binder. | ||
/// </summary> | ||
public SerializationBinder? Binder { get; set; } | ||
|
||
/// <summary> | ||
/// Optional type <see cref="ISerializationSurrogate"/> provider. | ||
/// </summary> | ||
public ISurrogateSelector? SurrogateSelector { get; set; } | ||
|
||
/// <summary> | ||
/// Streaming context. | ||
/// </summary> | ||
public StreamingContext StreamingContext { get; set; } = new(StreamingContextStates.All); | ||
} | ||
} | ||
|
||
#pragma warning restore SYSLIB0050 // Type or member is obsolete |
30 changes: 30 additions & 0 deletions
30
...tensions/src/System/Resources/Extensions/BinaryFormat/BinaryFormattedObject.ParseState.cs
This file contains 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,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Runtime.Serialization.BinaryFormat; | ||
|
||
namespace System.Resources.Extensions.BinaryFormat; | ||
|
||
internal sealed partial class BinaryFormattedObject | ||
{ | ||
/// <summary> | ||
/// Parsing state for <see cref="BinaryFormattedObject"/>. | ||
/// </summary> | ||
internal sealed class ParseState : IParseState | ||
{ | ||
private readonly BinaryFormattedObject _format; | ||
|
||
public ParseState(BinaryReader reader, BinaryFormattedObject format) | ||
{ | ||
Reader = reader; | ||
_format = format; | ||
} | ||
|
||
public BinaryReader Reader { get; } | ||
public IReadOnlyDictionary<int, SerializationRecord> RecordMap => _format.RecordMap; | ||
public Options Options => _format._options; | ||
public ITypeResolver TypeResolver => _format.TypeResolver; | ||
} | ||
} |
Oops, something went wrong.