Skip to content
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
@@ -0,0 +1,16 @@
using System;
using System.Threading;

namespace LogicBuilder.Workflow.ComponentModel
{
internal static class ExceptionUtility
{
internal static bool IsCriticalException(Exception ex)
{
return ex is OutOfMemoryException
or ThreadAbortException
or StackOverflowException
or ThreadInterruptedException;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.CodeDom;
using System;
using System.Collections.Generic;
using System;
using System.CodeDom;
using System.Globalization;
using System.Text;

Expand Down Expand Up @@ -83,7 +82,7 @@ protected internal override object DeserializeFromString(WorkflowMarkupSerializa
return result;
}
}
catch (Exception)
catch (Exception ex) when (!ExceptionUtility.IsCriticalException(ex))
{
// something went wrong getting the type, so simply pass in the string and
// let CodeTypeReference figure it out. Note that CodeTypeReference has a method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ PropertyInfo serializableProperty in properties.Where
}
}
}
catch (Exception ex)
catch (Exception ex) when (!ExceptionUtility.IsCriticalException(ex))
{
serializationManager.ReportError(new WorkflowMarkupSerializationException(SR.GetString(SR.Error_SerializerNoSerializeLogic, [serializableProperty.Name, value.GetType().FullName]), ex));
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ public class WorkflowMarkupSerializationManager : IDesignerSerializationManager
{
private Assembly localAssembly = null;
private int writerDepth = 0;
private readonly ContextStack workflowMarkupStack = new ContextStack();
private readonly ContextStack workflowMarkupStack = new();
// Stack to keep a list of objects being serialized, to avoid stack overflow
private readonly Stack serializationStack = new Stack();
private readonly Stack serializationStack = new();
private IDesignerSerializationManager serializationManager;
private readonly bool designMode = false;
internal event EventHandler<WorkflowMarkupElementEventArgs> FoundDefTag;

//These are temporary variables for speedy lookup
private readonly Dictionary<int, WorkflowMarkupSerializerMapping> clrNamespaceBasedMappings = new Dictionary<int, WorkflowMarkupSerializerMapping>();
private readonly Dictionary<string, List<WorkflowMarkupSerializerMapping>> xmlNamespaceBasedMappings = new Dictionary<string, List<WorkflowMarkupSerializerMapping>>();
private readonly Dictionary<string, List<WorkflowMarkupSerializerMapping>> prefixBasedMappings = new Dictionary<string, List<WorkflowMarkupSerializerMapping>>();
private readonly Dictionary<int, WorkflowMarkupSerializerMapping> clrNamespaceBasedMappings = [];
private readonly Dictionary<string, List<WorkflowMarkupSerializerMapping>> xmlNamespaceBasedMappings = [];
private readonly Dictionary<string, List<WorkflowMarkupSerializerMapping>> prefixBasedMappings = [];
private List<WorkflowMarkupSerializer> extendedPropertiesProviders;
private readonly Dictionary<XmlQualifiedName, Type> cachedXmlQualifiedNameTypes = new Dictionary<XmlQualifiedName, Type>();
private readonly Dictionary<XmlQualifiedName, Type> cachedXmlQualifiedNameTypes = [];

public WorkflowMarkupSerializationManager(IDesignerSerializationManager manager)
{
Expand Down Expand Up @@ -122,7 +122,7 @@ public virtual XmlQualifiedName GetXmlQualifiedName(Type type, out string prefix
if (!this.clrNamespaceBasedMappings.TryGetValue(key, out WorkflowMarkupSerializerMapping mappingForType))
{
WorkflowMarkupSerializerMapping.GetMappingFromType(this, type, out mappingForType, out IList<WorkflowMarkupSerializerMapping> collectedMappings);
AddMappings(new List<WorkflowMarkupSerializerMapping>(new WorkflowMarkupSerializerMapping[] { mappingForType }));
AddMappings(new List<WorkflowMarkupSerializerMapping>([mappingForType]));
AddMappings(collectedMappings);
}

Expand Down Expand Up @@ -160,7 +160,7 @@ public virtual Type GetType(XmlQualifiedName xmlQualifiedName)
AddMappings(matchingMappings);
AddMappings(collectedMappings);

xmlnsMappings = new List<WorkflowMarkupSerializerMapping>(matchingMappings);
xmlnsMappings = [.. matchingMappings];
}

foreach (WorkflowMarkupSerializerMapping xmlnsMapping in xmlnsMappings)
Expand Down Expand Up @@ -194,12 +194,8 @@ public virtual Type GetType(XmlQualifiedName xmlQualifiedName)
{
resolvedType = GetType(assemblyQualifiedName);
}
catch
catch (Exception ex) when (!ExceptionUtility.IsCriticalException(ex))
{
//



}

if (resolvedType == null)
Expand Down Expand Up @@ -246,9 +242,8 @@ public virtual Type GetType(string typeName)
{
type = this.serializationManager.GetType(typeName);
}
catch
catch (Exception ex) when (!ExceptionUtility.IsCriticalException(ex))
{
//Debug.Assert(false, "VSIP framwork threw exception on resolving type." + e.ToString());
}
}

Expand Down Expand Up @@ -276,11 +271,8 @@ public virtual Type GetType(string typeName)
{
assembly = Assembly.Load(assemblyName);
}
catch
catch (Exception ex) when (!ExceptionUtility.IsCriticalException(ex))
{
//


}
}

Expand Down Expand Up @@ -352,14 +344,14 @@ internal void AddMappings(IList<WorkflowMarkupSerializerMapping> mappingsToAdd)

if (!this.xmlNamespaceBasedMappings.TryGetValue(mapping.XmlNamespace, out List<WorkflowMarkupSerializerMapping> xmlnsMappings))
{
xmlnsMappings = new List<WorkflowMarkupSerializerMapping>();
xmlnsMappings = [];
this.xmlNamespaceBasedMappings.Add(mapping.XmlNamespace, xmlnsMappings);
}
xmlnsMappings.Add(mapping);

if (!this.prefixBasedMappings.TryGetValue(mapping.Prefix, out List<WorkflowMarkupSerializerMapping> prefixMappings))
{
prefixMappings = new List<WorkflowMarkupSerializerMapping>();
prefixMappings = [];
this.prefixBasedMappings.Add(mapping.Prefix, prefixMappings);
}
prefixMappings.Add(mapping);
Expand All @@ -370,18 +362,17 @@ internal IList<WorkflowMarkupSerializer> ExtendedPropertiesProviders
{
get
{
if (this.extendedPropertiesProviders == null)
this.extendedPropertiesProviders = new List<WorkflowMarkupSerializer>();
this.extendedPropertiesProviders ??= [];
return this.extendedPropertiesProviders;
}
}

internal ExtendedPropertyInfo[] GetExtendedProperties(object extendee)
{
List<ExtendedPropertyInfo> extendedProperties = new List<ExtendedPropertyInfo>();
List<ExtendedPropertyInfo> extendedProperties = [];
foreach (WorkflowMarkupSerializer markupSerializer in ExtendedPropertiesProviders)
extendedProperties.AddRange(markupSerializer.GetExtendedProperties(this, extendee));
return extendedProperties.ToArray();
return [.. extendedProperties];
}
#endregion

Expand Down
Loading