Skip to content

Commit 26d8ce6

Browse files
author
Michael Ganss
committed
Fix sonarcloud issues
1 parent 0ed7e5c commit 26d8ce6

File tree

4 files changed

+4
-32
lines changed

4 files changed

+4
-32
lines changed

XmlSchemaClassGenerator/Extensions.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TS
2727
return source.GroupBy(propertySelector).Select(x => x.First());
2828
}
2929

30-
public static string QuoteIfNeeded(this string text)
31-
{
32-
return string.IsNullOrEmpty(text) ? text
33-
: text.Contains(" ") ? "\"" + text + "\""
34-
: text;
35-
}
30+
public static string QuoteIfNeeded(this string text) => !string.IsNullOrEmpty(text) && text.Contains(" ") ? "\"" + text + "\"" : text;
3631
}
3732
}

XmlSchemaClassGenerator/IXmlSchemaNode.cs

-24
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ namespace XmlSchemaClassGenerator
55
{
66
public interface IXmlSchemaNode
77
{
8-
//string Name { get; }
98
string DefaultValue { get; }
109
string FixedValue { get; }
1110
XmlSchemaForm Form { get; }
1211
XmlQualifiedName QualifiedName { get; }
1312
XmlQualifiedName RefName { get; }
14-
//XmlQualifiedName SchemaTypeName { get; }
15-
//XmlSchemaType SchemaType { get; }
16-
//XmlSchemaType NodeSchemaType { get; }
1713

1814
XmlSchemaAnnotated Base { get; }
1915
XmlSchemaForm FormDefault { get; }
@@ -25,24 +21,14 @@ public sealed class XmlSchemaAttributeEx : IXmlSchemaNode
2521

2622
public XmlSchemaAttribute Real { get; }
2723

28-
//public string Name => Real.Name;
2924
public string DefaultValue => Real.DefaultValue;
3025
public string FixedValue => Real.FixedValue;
3126
public XmlSchemaForm Form => Real.Form;
3227
public XmlQualifiedName QualifiedName => Real.QualifiedName;
3328
public XmlQualifiedName RefName => Real.RefName;
34-
//public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName;
35-
//public XmlSchemaSimpleType SchemaType => Real.SchemaType;
3629
public XmlSchemaSimpleType AttributeSchemaType => Real.AttributeSchemaType;
37-
3830
public XmlSchemaAnnotated Base => Real;
39-
4031
public XmlSchemaForm FormDefault => Base.GetSchema().AttributeFormDefault;
41-
42-
//XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType;
43-
44-
//XmlSchemaType IXmlSchemaNode.NodeSchemaType => AttributeSchemaType;
45-
4632
public XmlSchemaUse Use => Real.Use;
4733

4834
public static implicit operator XmlSchemaAttributeEx(XmlSchemaAttribute xs) => new(xs);
@@ -55,24 +41,14 @@ public sealed class XmlSchemaElementEx : IXmlSchemaNode
5541

5642
public XmlSchemaElement Real { get; }
5743

58-
//public string Name => Real.Name;
5944
public string DefaultValue => Real.DefaultValue;
6045
public string FixedValue => Real.FixedValue;
6146
public XmlSchemaForm Form => Real.Form;
6247
public XmlQualifiedName QualifiedName => Real.QualifiedName;
6348
public XmlQualifiedName RefName => Real.RefName;
64-
//public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName;
65-
//public XmlSchemaType SchemaType => Real.SchemaType;
6649
public XmlSchemaType ElementSchemaType => Real.ElementSchemaType;
67-
6850
public XmlSchemaAnnotated Base => Real;
69-
7051
public XmlSchemaForm FormDefault => Base.GetSchema().ElementFormDefault;
71-
72-
//XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType;
73-
74-
//XmlSchemaType IXmlSchemaNode.NodeSchemaType => ElementSchemaType;
75-
7652
public bool IsNillable => Real.IsNillable;
7753

7854
public static implicit operator XmlSchemaElementEx(XmlSchemaElement xs) => new(xs);

XmlSchemaClassGenerator/ModelBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ private TypeModel CreateTypeModel(XmlQualifiedName qualifiedName, XmlSchemaAnnot
380380
return typeModelBuilder.Create(type);
381381
}
382382

383-
private class TypeModelBuilder
383+
private sealed class TypeModelBuilder
384384
{
385385
private readonly ModelBuilder builder;
386386
private readonly GeneratorConfiguration _configuration;

XmlSchemaClassGenerator/TypeModel.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,14 @@ public void SetSchemaNameAndNamespace(TypeModel owningTypeModel, IXmlSchemaNode
560560

561561
internal static string GetAccessors(CodeMemberField backingField = null, bool withDataBinding = false, PropertyValueTypeCode typeCode = PropertyValueTypeCode.Other, bool privateSetter = false)
562562
{
563+
var privateString = privateSetter ? "private " : string.Empty;
563564
return backingField == null ? " { get; set; }" : CodeUtilities.NormalizeNewlines($@"
564565
{{
565566
get
566567
{{
567568
return {backingField.Name};
568569
}}
569-
{(privateSetter ? "private " : string.Empty)}set
570+
{privateString}set
570571
{{{(typeCode, withDataBinding) switch
571572
{
572573
(PropertyValueTypeCode.ValueType, true) => $@"

0 commit comments

Comments
 (0)