Skip to content

Commit 485d990

Browse files
author
Michael Ganss
committed
Fix sonarcloud issues
1 parent 2ede85a commit 485d990

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

XmlSchemaClassGenerator/ModelBuilder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ private void RemoveDuplicateInterfaceProperties()
158158
foreach (var interfaceModel in Types.Values.OfType<InterfaceModel>())
159159
{
160160
var parentProperties = interfaceModel.Properties.ToList();
161-
foreach (var baseInterfaceType in interfaceModel.AllDerivedReferenceTypes().OfType<InterfaceModel>())
161+
foreach (var baseInterfaceTypeProperties in interfaceModel.AllDerivedReferenceTypes().OfType<InterfaceModel>().Select(i => i.Properties))
162162
{
163163
foreach (var parentProperty in parentProperties)
164164
{
165-
var baseProperties = baseInterfaceType.Properties.ToList();
165+
var baseProperties = baseInterfaceTypeProperties.ToList();
166166
foreach (var baseProperty in baseProperties.Where(baseProperty => parentProperty.Name == baseProperty.Name && parentProperty.Type.Name == baseProperty.Type.Name))
167167
{
168-
baseInterfaceType.Properties.Remove(baseProperty);
168+
baseInterfaceTypeProperties.Remove(baseProperty);
169169
}
170170
}
171171
}
@@ -223,10 +223,10 @@ private void ResolveDependencies(XmlSchema schema, List<XmlSchema> dependencyOrd
223223

224224
if (imports.Any())
225225
{
226-
foreach (var import in imports)
226+
foreach (var importSchema in imports.Select(i => i.Schema))
227227
{
228-
if (import.Schema != null)
229-
ResolveDependencies(import.Schema, dependencyOrder, seenSchemas);
228+
if (importSchema != null)
229+
ResolveDependencies(importSchema, dependencyOrder, seenSchemas);
230230
}
231231
}
232232

XmlSchemaClassGenerator/OutputWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected void Write(TextWriter writer, CodeCompileUnit cu)
3333
/// A wrapper around <see cref="TextWriter"/> that removes semicolons after a closing brace
3434
/// due to a bug in CodeDom and auto-properties
3535
/// </summary>
36-
private class SemicolonRemovalTextWriter : TextWriter
36+
private sealed class SemicolonRemovalTextWriter : TextWriter
3737
{
3838
private readonly TextWriter _other;
3939

XmlSchemaClassGenerator/TypeModel.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,38 +1251,38 @@ private IEnumerable<CodeAttributeDeclaration> GetAttributes(bool isArray, TypeMo
12511251
attributes.Add(arrayAttribute);
12521252
}
12531253

1254-
foreach (var attribute in attributes)
1254+
foreach (var args in attributes.Select(a => a.Arguments))
12551255
{
1256-
bool namespacePrecalculated = attribute.Arguments.OfType<CodeAttributeArgument>().Any(a => a.Name == "Namespace");
1256+
bool namespacePrecalculated = args.OfType<CodeAttributeArgument>().Any(a => a.Name == "Namespace");
12571257
if (!namespacePrecalculated)
12581258
{
12591259
if (XmlNamespace != null)
12601260
{
1261-
attribute.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(XmlNamespace)));
1261+
args.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(XmlNamespace)));
12621262
}
12631263

12641264
if (Form == XmlSchemaForm.Qualified && IsAttribute)
12651265
{
12661266
if (XmlNamespace == null)
12671267
{
1268-
attribute.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(OwningType.XmlSchemaName.Namespace)));
1268+
args.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(OwningType.XmlSchemaName.Namespace)));
12691269
}
12701270

1271-
attribute.Arguments.Add(new CodeAttributeArgument("Form",
1271+
args.Add(new CodeAttributeArgument("Form",
12721272
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(CodeUtilities.CreateTypeReference(typeof(XmlSchemaForm), Configuration)),
12731273
"Qualified")));
12741274
}
12751275
else if ((Form == XmlSchemaForm.Unqualified || Form == XmlSchemaForm.None) && !IsAttribute && !IsAny && XmlNamespace == null)
12761276
{
1277-
attribute.Arguments.Add(new CodeAttributeArgument("Form",
1277+
args.Add(new CodeAttributeArgument("Form",
12781278
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(CodeUtilities.CreateTypeReference(typeof(XmlSchemaForm), Configuration)),
12791279
"Unqualified")));
12801280
}
12811281
}
12821282

12831283
if (IsNillable && !(IsCollection && Type is SimpleModel m && m.ValueType.IsValueType) && !(IsNullable && Configuration.DoNotForceIsNullable))
12841284
{
1285-
attribute.Arguments.Add(new CodeAttributeArgument("IsNullable", new CodePrimitiveExpression(true)));
1285+
args.Add(new CodeAttributeArgument("IsNullable", new CodePrimitiveExpression(true)));
12861286
}
12871287

12881288
if (Type is SimpleModel simpleModel && simpleModel.UseDataTypeAttribute)
@@ -1295,7 +1295,7 @@ private IEnumerable<CodeAttributeDeclaration> GetAttributes(bool isArray, TypeMo
12951295
if (name.Namespace == XmlSchema.Namespace && name.Name != "anySimpleType")
12961296
{
12971297
var dataType = new CodeAttributeArgument("DataType", new CodePrimitiveExpression(name.Name));
1298-
attribute.Arguments.Add(dataType);
1298+
args.Add(dataType);
12991299
break;
13001300
}
13011301
else

0 commit comments

Comments
 (0)