Skip to content

Commit

Permalink
Fix sonarcloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Jun 16, 2022
1 parent 0ed7e5c commit 26d8ce6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 32 deletions.
7 changes: 1 addition & 6 deletions XmlSchemaClassGenerator/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TS
return source.GroupBy(propertySelector).Select(x => x.First());
}

public static string QuoteIfNeeded(this string text)
{
return string.IsNullOrEmpty(text) ? text
: text.Contains(" ") ? "\"" + text + "\""
: text;
}
public static string QuoteIfNeeded(this string text) => !string.IsNullOrEmpty(text) && text.Contains(" ") ? "\"" + text + "\"" : text;
}
}
24 changes: 0 additions & 24 deletions XmlSchemaClassGenerator/IXmlSchemaNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ namespace XmlSchemaClassGenerator
{
public interface IXmlSchemaNode
{
//string Name { get; }
string DefaultValue { get; }
string FixedValue { get; }
XmlSchemaForm Form { get; }
XmlQualifiedName QualifiedName { get; }
XmlQualifiedName RefName { get; }
//XmlQualifiedName SchemaTypeName { get; }
//XmlSchemaType SchemaType { get; }
//XmlSchemaType NodeSchemaType { get; }

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

public XmlSchemaAttribute Real { get; }

//public string Name => Real.Name;
public string DefaultValue => Real.DefaultValue;
public string FixedValue => Real.FixedValue;
public XmlSchemaForm Form => Real.Form;
public XmlQualifiedName QualifiedName => Real.QualifiedName;
public XmlQualifiedName RefName => Real.RefName;
//public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName;
//public XmlSchemaSimpleType SchemaType => Real.SchemaType;
public XmlSchemaSimpleType AttributeSchemaType => Real.AttributeSchemaType;

public XmlSchemaAnnotated Base => Real;

public XmlSchemaForm FormDefault => Base.GetSchema().AttributeFormDefault;

//XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType;

//XmlSchemaType IXmlSchemaNode.NodeSchemaType => AttributeSchemaType;

public XmlSchemaUse Use => Real.Use;

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

public XmlSchemaElement Real { get; }

//public string Name => Real.Name;
public string DefaultValue => Real.DefaultValue;
public string FixedValue => Real.FixedValue;
public XmlSchemaForm Form => Real.Form;
public XmlQualifiedName QualifiedName => Real.QualifiedName;
public XmlQualifiedName RefName => Real.RefName;
//public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName;
//public XmlSchemaType SchemaType => Real.SchemaType;
public XmlSchemaType ElementSchemaType => Real.ElementSchemaType;

public XmlSchemaAnnotated Base => Real;

public XmlSchemaForm FormDefault => Base.GetSchema().ElementFormDefault;

//XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType;

//XmlSchemaType IXmlSchemaNode.NodeSchemaType => ElementSchemaType;

public bool IsNillable => Real.IsNillable;

public static implicit operator XmlSchemaElementEx(XmlSchemaElement xs) => new(xs);
Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator/ModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private TypeModel CreateTypeModel(XmlQualifiedName qualifiedName, XmlSchemaAnnot
return typeModelBuilder.Create(type);
}

private class TypeModelBuilder
private sealed class TypeModelBuilder
{
private readonly ModelBuilder builder;
private readonly GeneratorConfiguration _configuration;
Expand Down
3 changes: 2 additions & 1 deletion XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,14 @@ public void SetSchemaNameAndNamespace(TypeModel owningTypeModel, IXmlSchemaNode

internal static string GetAccessors(CodeMemberField backingField = null, bool withDataBinding = false, PropertyValueTypeCode typeCode = PropertyValueTypeCode.Other, bool privateSetter = false)
{
var privateString = privateSetter ? "private " : string.Empty;
return backingField == null ? " { get; set; }" : CodeUtilities.NormalizeNewlines($@"
{{
get
{{
return {backingField.Name};
}}
{(privateSetter ? "private " : string.Empty)}set
{privateString}set
{{{(typeCode, withDataBinding) switch
{
(PropertyValueTypeCode.ValueType, true) => $@"
Expand Down

0 comments on commit 26d8ce6

Please sign in to comment.