Skip to content

Remove dependency on Type.IsSerializable from OptionSet serialization#54990

Merged
CyrusNajmabadi merged 1 commit intodotnet:mainfrom
CyrusNajmabadi:optionSetSerialization
Jul 20, 2021
Merged

Remove dependency on Type.IsSerializable from OptionSet serialization#54990
CyrusNajmabadi merged 1 commit intodotnet:mainfrom
CyrusNajmabadi:optionSetSerialization

Conversation

@CyrusNajmabadi
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Jul 20, 2021

Previous code depended on both sides of the OOP communication channel agreeing on what types are serializable or not. new code does not.

@CyrusNajmabadi CyrusNajmabadi requested review from genlu and tmat July 20, 2021 20:29
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner July 20, 2021 20:29
@ghost ghost added the Area-IDE label Jul 20, 2021

private enum OptionValueKind
{
Null,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Null and String and Serializable were merged into a single item called 'Object'

}

var kind = OptionValueKind.Null;
object? valueToWrite = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to specially handle 'null', the default case below handles it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, no need for 'valueToWrite'. we always just write out the literal value.

@@ -215,57 +215,28 @@ public void Serialize(ObjectWriter writer, CancellationToken cancellationToken)
Debug.Assert(ShouldSerialize(optionKey));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should view with whitespace off.

if (type.IsEnum)
{
kind = OptionValueKind.Enum;
valueToWrite = (int)value;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this cast isn't necessary here due to teh line where we actually write the enum doing this already.


case OptionValueKind.Null:
optionValue = null;
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this. already handled by the object reading code.


case ICodeStyleOption:
if (optionKey.Option.Type.GenericTypeArguments.Length != 1)
continue;
Copy link
Member

@tmat tmat Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just ignore options without single generic type param? Shouldn't this throw or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am adding this to the list of things to try out in my followup PR :) but yes. seems insane.

@CyrusNajmabadi CyrusNajmabadi requested a review from tmat July 20, 2021 20:58
Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge July 20, 2021 21:07
@CyrusNajmabadi CyrusNajmabadi merged commit 87f1664 into dotnet:main Jul 20, 2021
@ghost ghost added this to the Next milestone Jul 20, 2021
@CyrusNajmabadi CyrusNajmabadi deleted the optionSetSerialization branch July 21, 2021 02:50
@allisonchou allisonchou modified the milestones: Next, 17.0.P3 Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants