Skip to content
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

Refactor CodeDomComponentSerializationService to use List<T> instead of ArrayList #8214

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private sealed class CodeDomSerializationStore : SerializationStore, ISerializab
private readonly IServiceProvider _provider;

// These fields persist across the store
private readonly ArrayList _objectNames;
private readonly List<string> _objectNames;
private Hashtable _objectState;
private LocalResourceManager _resources;
private AssemblyName[] _assemblies;
Expand All @@ -212,7 +212,7 @@ internal CodeDomSerializationStore(IServiceProvider provider)
{
_provider = provider;
_objects = new Hashtable();
_objectNames = new ArrayList();
_objectNames = new List<string>();
_shimObjectNames = new List<string>();
}

Expand Down Expand Up @@ -613,7 +613,7 @@ private class ComponentListCodeDomSerializer : CodeDomSerializer
{
internal static ComponentListCodeDomSerializer s_instance = new ComponentListCodeDomSerializer();
private Hashtable _statementsTable;
Dictionary<string, ArrayList> _expressions;
Dictionary<string, List<CodeExpression>> _expressions;
private Hashtable _objectState; // only used during deserialization
private bool _applyDefaults = true;
private readonly Hashtable _nameResolveGuard = new Hashtable();
Expand All @@ -636,15 +636,9 @@ private void PopulateCompleteStatements(object data, string name, CodeStatementC
else if (data is CodeExpression expression)
{
// we handle expressions a little differently since they don't have a LHS or RHS they won't show up correctly in the statement table. We will deserialize them explicitly.
ArrayList exps = null;
if (_expressions.ContainsKey(name))
if (!_expressions.TryGetValue(name, out List<CodeExpression> exps))
{
exps = _expressions[name];
}

if (exps is null)
{
exps = new ArrayList();
exps = new();
_expressions[name] = exps;
}

Expand All @@ -662,7 +656,7 @@ private void PopulateCompleteStatements(object data, string name, CodeStatementC
internal void Deserialize(IDesignerSerializationManager manager, IDictionary objectState, IList objectNames, bool applyDefaults)
{
CodeStatementCollection completeStatements = new CodeStatementCollection();
_expressions = new Dictionary<string, ArrayList>();
_expressions = new();
_applyDefaults = applyDefaults;
foreach (string name in objectNames)
{
Expand Down Expand Up @@ -957,7 +951,7 @@ private bool ResolveName(IDesignerSerializationManager manager, string name, boo
DeserializeModifier(manager, name, state[StateModifier]);
}

if (_expressions.TryGetValue(name, out ArrayList exps))
if (_expressions.TryGetValue(name, out List<CodeExpression> exps))
{
foreach (CodeExpression exp in exps)
{
Expand All @@ -974,7 +968,7 @@ private bool ResolveName(IDesignerSerializationManager manager, string name, boo
if (!resolved)
{
// this is condition 2 of the comment at the start of this method.
if (_expressions.TryGetValue(name, out ArrayList exps))
if (_expressions.TryGetValue(name, out List<CodeExpression> exps))
{
foreach (CodeExpression exp in exps)
{
Expand Down
Loading