Skip to content

Commit

Permalink
Remove unused locals and methods in System.Private.Xml
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKotsenas committed Sep 15, 2020
1 parent 7dfdcc3 commit c6aea7a
Show file tree
Hide file tree
Showing 37 changed files with 41 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,6 @@ public override ReadState ReadState
// Skips to the end tag of the current element.
public override void Skip()
{
int startDepth = Depth;
switch (NodeType)
{
case XmlNodeType.Element:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ public override Task<bool> ReadAsync()
// Skips to the end tag of the current element.
public override async Task SkipAsync()
{
int startDepth = Depth;
switch (NodeType)
{
case XmlNodeType.Element:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public virtual XmlNode ReplaceChild(XmlNode newChild, XmlNode oldChild)
{
XmlNode? nextNode = oldChild.NextSibling;
RemoveChild(oldChild);
XmlNode? node = InsertBefore(newChild, nextNode);
InsertBefore(newChild, nextNode);
return oldChild;
}

Expand Down Expand Up @@ -846,7 +846,6 @@ public virtual bool IsReadOnly
{
get
{
XmlDocument? doc = OwnerDocument;
return HasReadOnlyParent(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,6 @@ public ContentValidator Finish(bool useDFA)
{
if (ContentType == XmlSchemaContentType.Mixed)
{
string ctype = IsOpen ? "Any" : "TextOnly";
return IsOpen ? ContentValidator.Any : ContentValidator.TextOnly;
}
else
Expand All @@ -1281,7 +1280,6 @@ public ContentValidator Finish(bool useDFA)
_contentNode.ExpandTree(contentRoot, _symbols, _positions);

// calculate followpos
int symbolsCount = _symbols.Count;
int positionsCount = _positions.Count;
BitSet firstpos = new BitSet(positionsCount);
BitSet lastpos = new BitSet(positionsCount);
Expand Down Expand Up @@ -1536,50 +1534,6 @@ private void CheckUniqueParticleAttribution(BitSet curpos)
// now convert transition table to array
return (int[][])transitionTable.ToArray(typeof(int[]));
}

#if DEBUG
private void Dump(StringBuilder bb, BitSet[] followpos, int[][] transitionTable)
{
// Temporary printout
bb.AppendLine("Positions");
for (int i = 0; i < _positions!.Count; i++)
{
bb.AppendLine(i + " " + _positions[i].symbol.ToString(NumberFormatInfo.InvariantInfo) + " " + _symbols!.NameOf(_positions[i].symbol));
}

bb.AppendLine("Followpos");
for (int i = 0; i < _positions.Count; i++)
{
for (int j = 0; j < _positions.Count; j++)
{
bb.Append(followpos[i][j] ? "X" : "O");
}
bb.AppendLine();
}

if (transitionTable != null)
{
// Temporary printout
bb.AppendLine("Transitions");
for (int i = 0; i < transitionTable.Length; i++)
{
for (int j = 0; j < _symbols!.Count; j++)
{
if (transitionTable[i][j] == -1)
{
bb.Append(" x ");
}
else
{
bb.AppendFormat(" {0:000} ", transitionTable[i][j]);
}
}

bb.AppendLine(transitionTable[i][_symbols.Count] == 1 ? "+" : "");
}
}
}
#endif
}

/// <summary>
Expand Down Expand Up @@ -1880,7 +1834,6 @@ internal RangeContentValidator(

public override void InitValidation(ValidationState context)
{
int positionsCount = _positions.Count;
List<RangePositionInfo>? runningPositions = context.RunningPositions;
if (runningPositions != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ private void CheckValue(object value, XmlSchemaFacet facet)

internal void CompileFacetCombinations()
{
RestrictionFacets baseRestriction = _datatype.Restriction!;
//They are not allowed on the same type but allowed on derived types.
if (
(_derivedRestriction.Flags & RestrictionFlags.MaxInclusive) != 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ internal void InferElement(XmlSchemaElement xse, bool bCreatingNewType, XmlSchem
throw new XmlSchemaInferenceException(SR.SchInf_particle, 0, 0);
ct.Particle = new XmlSchemaSequence();
bCreatingNewSequence = true;
XmlSchemaElement subelement = AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1);
AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1);
lastUsedSeqItem = 0;
if (!bCreatingNewType)
ct.Particle.MinOccurs = 0; //previously this was simple type so subelements did not exist
Expand All @@ -934,7 +934,7 @@ internal void InferElement(XmlSchemaElement xse, bool bCreatingNewType, XmlSchem
{
ct.Particle = new XmlSchemaSequence();
bCreatingNewSequence = true;
XmlSchemaElement subelement = AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1);
AddElement(_xtr.LocalName, _xtr.Prefix, _xtr.NamespaceURI, parentSchema, ((XmlSchemaSequence)ct.Particle).Items, -1);
if (!bCreatingNewType)
{
((XmlSchemaSequence)ct.Particle).MinOccurs = decimal.Zero;
Expand All @@ -946,7 +946,7 @@ internal void InferElement(XmlSchemaElement xse, bool bCreatingNewType, XmlSchem
else
{
bool bParticleChanged = false;
XmlSchemaElement subelement = FindMatchingElement(bCreatingNewType || bCreatingNewSequence, _xtr, ct, ref lastUsedSeqItem, ref bParticleChanged, parentSchema, Maxoccursflag);
FindMatchingElement(bCreatingNewType || bCreatingNewSequence, _xtr, ct, ref lastUsedSeqItem, ref bParticleChanged, parentSchema, Maxoccursflag);
}
}
else if (_xtr.NodeType == XmlNodeType.Text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2439,98 +2439,6 @@ private ContentValidator CompileComplexContent(XmlSchemaComplexType complexType)
}
}

#if DEBUG
private string DumpContentModel(XmlSchemaParticle particle)
{
StringBuilder sb = new StringBuilder();
DumpContentModelTo(sb, particle);
return sb.ToString();
}

private void DumpContentModelTo(StringBuilder sb, XmlSchemaParticle particle)
{
if (particle is XmlSchemaElement)
{
sb.Append(((XmlSchemaElement)particle).QualifiedName);
}
else if (particle is XmlSchemaAny)
{
sb.Append('<');
sb.Append(((XmlSchemaAny)particle!).NamespaceList!.ToString());
sb.Append('>');
}
else if (particle is XmlSchemaAll)
{
XmlSchemaAll all = (XmlSchemaAll)particle;
sb.Append('[');
bool first = true;
for (int i = 0; i < all.Items.Count; ++i)
{
XmlSchemaElement localElement = (XmlSchemaElement)all.Items[i];
if (first)
{
first = false;
}
else
{
sb.Append(", ");
}
sb.Append(localElement.QualifiedName.Name);
if (localElement.MinOccurs == decimal.Zero)
{
sb.Append('?');
}
}
sb.Append(']');
}
else if (particle is XmlSchemaGroupBase)
{
XmlSchemaGroupBase gb = (XmlSchemaGroupBase)particle;
sb.Append('(');
string delimeter = (particle is XmlSchemaChoice) ? " | " : ", ";
bool first = true;
for (int i = 0; i < gb.Items.Count; ++i)
{
if (first)
{
first = false;
}
else
{
sb.Append(delimeter);
}
DumpContentModelTo(sb, (XmlSchemaParticle)gb.Items[i]);
}
sb.Append(')');
}
else
{
Debug.Assert(particle == XmlSchemaParticle.Empty);
sb.Append("<>");
}
if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.One)
{
// nothing
}
else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.One)
{
sb.Append('?');
}
else if (particle.MinOccurs == decimal.Zero && particle.MaxOccurs == decimal.MaxValue)
{
sb.Append('*');
}
else if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.MaxValue)
{
sb.Append('+');
}
else
{
sb.Append("{" + particle.MinOccurs.ToString(NumberFormatInfo.InvariantInfo) + ", " + particle.MaxOccurs.ToString(NumberFormatInfo.InvariantInfo) + "}");
}
}
#endif

private void BuildParticleContentModel(ParticleContentValidator contentValidator, XmlSchemaParticle particle)
{
if (particle is XmlSchemaElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal void AddImport(Type? type, Hashtable types)
{
TypeForwardedFromAttribute? originalAssemblyInfo = typeForwardedFromAttribute[0] as TypeForwardedFromAttribute;
Debug.Assert(originalAssemblyInfo != null);
Assembly originalAssembly = Assembly.Load(new AssemblyName(originalAssemblyInfo.AssemblyFullName));
Assembly.Load(new AssemblyName(originalAssemblyInfo.AssemblyFullName));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -998,18 +998,6 @@ internal int SequenceId
set { _sequenceId = value; }
}

private string GetNullableType(TypeDesc td)
{
// SOAP encoded arrays not mapped to Nullable<T> since they always derive from soapenc:Array
if (td.IsMappedType || (!td.IsValueType && (Elements![0].IsSoap || td.ArrayElementTypeDesc == null)))
return td.FullName;
if (td.ArrayElementTypeDesc != null)
{
return GetNullableType(td.ArrayElementTypeDesc) + "[]";
}
return "System.Nullable`1[" + td.FullName + "]";
}

internal MemberMapping Clone()
{
return new MemberMapping(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,6 @@ private XmlSerializationCollectionFixupCallback GetCreateCollectionOfObjectsCall
}

Member[] allMembers = allMembersList.ToArray();
MemberMapping[] allMemberMappings = allMemberMappingList.ToArray();

UnknownNodeAction unknownNodeAction = (_) => UnknownNode(o);
WriteAttributes(allMembers, anyAttribute, unknownNodeAction, ref o);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ private void WriteElements(object? o, object? enumSource, ElementAccessor[] elem
int anyCount = 0;
var namedAnys = new List<ElementAccessor>();
ElementAccessor? unnamedAny = null; // can only have one
string? enumTypeName = (choice != null) ? choice.Mapping!.TypeDesc!.FullName : null;

for (int i = 0; i < elements.Length; i++)
{
Expand Down Expand Up @@ -357,7 +356,6 @@ private void WriteElement(object? o, ElementAccessor element, bool writeAccessor
}
else if (element.IsUnbounded)
{
TypeDesc arrayTypeDesc = mapping.TypeDesc!.CreateArrayTypeDesc();
var enumerable = (IEnumerable)o!;
foreach (var e in enumerable)
{
Expand Down Expand Up @@ -1217,7 +1215,6 @@ private void GenerateMembersElement(object o, XmlMembersMapping xmlMembersMappin
int xmlnsMember = FindXmlnsIndex(mapping.Members!);
if (xmlnsMember >= 0)
{
MemberMapping member = mapping.Members![xmlnsMember];
var source = (XmlSerializerNamespaces)p[xmlnsMember];

if (pLength > xmlnsMember)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,6 @@ private void Write43_XmlSchemaAll(XmlSchemaAll o)
private void Write46_XmlSchemaElement(XmlSchemaElement? o)
{
if ((object?)o == null) return;
System.Type t = o.GetType();
WriteStartElement("element");
WriteAttribute(@"id", @"", o.Id);
WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
Expand Down Expand Up @@ -1033,7 +1032,6 @@ private void Write46_XmlSchemaElement(XmlSchemaElement? o)
private void Write47_XmlSchemaKey(XmlSchemaKey? o)
{
if ((object?)o == null) return;
System.Type t = o.GetType();
WriteStartElement("key");
WriteAttribute(@"id", @"", ((string?)o.@Id));
WriteAttribute(@"name", @"", ((string?)o.@Name));
Expand Down Expand Up @@ -1088,7 +1086,6 @@ private void Write49_XmlSchemaXPath(string name, string ns, XmlSchemaXPath? o)
private void Write50_XmlSchemaKeyref(XmlSchemaKeyref? o)
{
if ((object?)o == null) return;
System.Type t = o.GetType();
WriteStartElement("keyref");

WriteAttribute(@"id", @"", ((string?)o.@Id));
Expand All @@ -1114,7 +1111,6 @@ private void Write50_XmlSchemaKeyref(XmlSchemaKeyref? o)
private void Write51_XmlSchemaUnique(XmlSchemaUnique? o)
{
if ((object?)o == null) return;
System.Type t = o.GetType();
WriteStartElement("unique");

WriteAttribute(@"id", @"", ((string?)o.@Id));
Expand All @@ -1136,7 +1132,6 @@ private void Write51_XmlSchemaUnique(XmlSchemaUnique? o)
private void Write52_XmlSchemaChoice(XmlSchemaChoice? o)
{
if ((object?)o == null) return;
System.Type t = o.GetType();
WriteStartElement("choice");

WriteAttribute(@"id", @"", ((string?)o.@Id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ protected XmlDocument Document
private void InitPrimitiveIDs()
{
if (_tokenID != null) return;
object ns = _r.NameTable.Add(XmlSchema.Namespace);
object ns2 = _r.NameTable.Add(UrtTypes.Namespace);
_ = _r.NameTable.Add(XmlSchema.Namespace);
_ = _r.NameTable.Add(UrtTypes.Namespace);

_stringID = _r.NameTable.Add("string");
_intID = _r.NameTable.Add("int");
Expand Down Expand Up @@ -2116,7 +2116,6 @@ internal Member(XmlSerializationReaderCodeGen outerClass, string source, string?
_arrayName = arrayName + "_" + i.ToString(CultureInfo.InvariantCulture);
_choiceArrayName = "choice_" + _arrayName;
_choiceSource = choiceSource;
ElementAccessor[]? elements = mapping.Elements;

if (mapping.TypeDesc!.IsArrayLike)
{
Expand Down Expand Up @@ -3426,7 +3425,6 @@ private void WriteEncodedStructMethod(StructMapping structMapping)
{
if (structMapping.TypeDesc!.IsRoot)
return;
bool useReflection = structMapping.TypeDesc.UseReflection;
string methodName = (string)MethodNames[structMapping]!;
Writer.WriteLine();
Writer.Write("object");
Expand Down Expand Up @@ -3566,7 +3564,6 @@ private void WriteFixupMethod(string? fixupMethodName, Member[] members, string
private void WriteAddCollectionFixup(TypeDesc typeDesc, bool readOnly, string memberSource, string targetSource)
{
Writer.WriteLine("// get array of the collection items");
bool useReflection = typeDesc.UseReflection;
CreateCollectionInfo? create = (CreateCollectionInfo?)_createMethods[typeDesc];
if (create == null)
{
Expand Down
Loading

0 comments on commit c6aea7a

Please sign in to comment.