Skip to content

Support parameter-less event methods in DataContractSerializer (without a StreamingContext parameter) #109264

Open
@Takym

Description

@Takym

When I use event methods for the DataContractSerializer system, I still need a StreamingContext parameter even though the BinaryFormatter stuff is deprecated. The constructor and state property of StreamingContext is marked as obsolete.

The StreamingContext _ parameter is unused in the below code. I feel it is redundant.

[OnSerializing()]
void OnSerializing(StreamingContext _) { ... }

[OnSerialized()]
void OnSerializing(StreamingContext _) { ... }

[OnDeserializing()]
void OnSerializing(StreamingContext _) { ... }

[OnDeserialized()]
void OnSerializing(StreamingContext _) { ... }

Parameter-less one like the code below makes me feel refreshed. Also, we do not need to type unused parameters. So, developing efficiency is more improved. In addition, maybe, passing (copying structure data) the parameter makes a program slow. Or maybe, the speed is the same because of checking parameters.

[OnSerializing()]
void OnSerializing() { ... }

[OnSerialized()]
void OnSerializing() { ... }

[OnDeserializing()]
void OnSerializing() { ... }

[OnDeserialized()]
void OnSerializing() { ... }

I agree that we should still support with StreamingContext _ parameter for compatibility but I want a parameter-less option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Serializationbinaryformatter-migrationIssues related to the removal of BinaryFormatter and migrations away from ituntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions