Skip to content

Commit

Permalink
Addressed Solution Warnings (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-E-angelo authored Jan 9, 2023
1 parent 3d5c9fd commit 5b777b4
Show file tree
Hide file tree
Showing 35 changed files with 85 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace ExtendedXmlSerializer.Samples.Generics
{
public class GenericSerializer
public class GenericSerializer
{
private IExtendedXmlSerializer serializer;

Expand Down Expand Up @@ -46,7 +46,7 @@ public static void SerializeAndDeserialize()


var data = srl.SerializeProject(prj);
var obj = srl.DeserializeProject<IProject>(data);
srl.DeserializeProject<IProject>(data);
}


Expand Down Expand Up @@ -78,20 +78,20 @@ public Project(string name, int id)
Id = id;
}

public string Name { get; set; } = "MY project";
public string Name { get; set; }
public int Id { get; }
public string Path => @"C:/my/fake/path";

public IList<ISite<IContext>> Sites { get; } = new List<ISite<IContext>>();
}

public class SpecificClass : SiteBase<Context>
public sealed class SpecificClass : SiteBase<Context>
{
public SpecificClass()
{
this.Name = "Specific class";
this.UserDescription = "Class description";
this.Context = new Context();
Name = "Specific class";
UserDescription = "Class description";
Context = new Context();
}


Expand All @@ -105,6 +105,7 @@ public abstract class SiteBase<TSiteContext> : ISite<TSiteContext> where TSiteCo
{
public string Name { get; set; }
public string UserDescription { get; set; }
// ReSharper disable once MemberHidesStaticFromOuterClass
public abstract TSiteContext Context { get; set; }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace ExtendedXmlSerializer.Samples.Parametrized
{
public static class ParametrizedConstructors
public static class ParametrizedConstructors
{
public static void SerializeAndDeserialize()
{
Expand All @@ -22,7 +22,7 @@ public static void SerializeAndDeserialize()
dt.Data.Add(7);

var data = srl.Serialize(dt);
var obj = dsrl.Deserialize<DataHolder>(data);
dsrl.Deserialize<DataHolder>(data);
}

public class DataHolder
Expand Down
6 changes: 3 additions & 3 deletions samples/ExtendedXmlSerializer.Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

namespace ExtendedXmlSerializer.Samples
{
using ExtendedXmlSerializer.Samples.Generics;
using ExtendedXmlSerializer.Samples.Parametrized;
using FluentApi;
using FluentApi;
using Generics;
using Parametrized;

public class Program
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;
using ExtendedXmlSerializer.Core;
using System.Reflection;

namespace ExtendedXmlSerializer.ContentModel.Conversion
{
Expand All @@ -11,7 +11,7 @@ sealed class StructureConverter<T> : IConverter<T?> where T : struct

public bool IsSatisfiedBy(TypeInfo parameter) => _converter.IsSatisfiedBy(parameter);

public T? Parse(string data) => data.NullIfEmpty() != null ? _converter.Parse(data) : (T?)null;
public T? Parse(string data) => data.NullIfEmpty() != null ? _converter.Parse(data) : null;

public string Format(T? instance) => instance.HasValue ? _converter.Format(instance.Value) : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Reflection;
using ExtendedXmlSerializer.Core.Specifications;
using ExtendedXmlSerializer.ReflectionModel;
using System.Reflection;

namespace ExtendedXmlSerializer.ContentModel.Members
{
Expand All @@ -21,7 +21,7 @@ public InstanceMemberSerializations(ISpecification<TypeInfo> specification,

public IInstanceMemberSerialization Get(TypeInfo parameter)
=> _specification.IsSatisfiedBy(parameter)
? (IInstanceMemberSerialization)new InstanceMemberSerialization(parameter, _serializations)
? new InstanceMemberSerialization(parameter, _serializations)
: new FixedInstanceMemberSerialization(_serializations.Get(parameter));
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Immutable;
using System.Linq;
using ExtendedXmlSerializer.ContentModel.Conversion;
using ExtendedXmlSerializer.ContentModel.Identification;
using ExtendedXmlSerializer.Core.Sources;
using System;
using System.Collections.Immutable;
using System.Linq;

namespace ExtendedXmlSerializer.ContentModel.Reflection
{
Expand All @@ -26,7 +26,7 @@ public TypeParts Get(TypeParts parameter)
arguments.HasValue
? arguments.Value.Select(_selector)
.ToImmutableArray
: (Func<ImmutableArray<TypeParts>>)null);
: null);
return result;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ExtendedXmlSerializer/Core/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static TValue Get<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> ta
where TValue : struct
=> AssignedSpecification<TKey>.Default.IsSatisfiedBy(key) && target.TryGetValue(key, out var result)
? result
: (TValue?)null;
: null;

public static IEnumerable<T> Appending<T>(this IEnumerable<T> @this, params T[] items) => @this.Concat(items);

Expand Down
2 changes: 1 addition & 1 deletion src/ExtendedXmlSerializer/Core/Parsing/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static T ParseAsOptional<T>(this Parser<T> @this, string data)
public static Func<T> Build<T>(this IOption<T> @this) => @this.IsDefined ? new Func<T>(@this.Get) : null;

public static T? GetAssigned<T>(this IOption<T> @this) where T : struct
=> @this.IsDefined ? @this.Get() : (T?)null;
=> @this.IsDefined ? @this.Get() : null;

public static T Get<T>(this IParsing<T> @this, string parameter) => @this.Get(Inputs.Default.Get(parameter))
.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ConditionalSource(ISpecification<TParameter> specification, ISpecificatio
/// <exclude />
public ConditionalSource(Func<TParameter, bool> specification, Func<TResult, bool> result,
Func<TParameter, TResult> source)
: this(specification, result, source, x => default) {}
: this(specification, result, source, _ => default) {}

/// <exclude />
public ConditionalSource(Func<TParameter, bool> specification, Func<TResult, bool> result,
Expand Down
4 changes: 2 additions & 2 deletions src/ExtendedXmlSerializer/Core/TypedSortOrder.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Reflection;
using ExtendedXmlSerializer.Core.Sources;
using System.Reflection;

namespace ExtendedXmlSerializer.Core
{
sealed class TypedSortOrder : StructureCache<TypeInfo, int>, ITypedSortOrder
{
public TypedSortOrder() : base(info => 1) {}
public TypedSortOrder() : base(_ => 1) {}
}
}
3 changes: 2 additions & 1 deletion src/ExtendedXmlSerializer/ExtendedXmlSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<Authors>Wojciech Nagórski;Michael DeMond</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>ExtendedXmlSerializer</AssemblyName>
<DocumentationFile>$(BaseIntermediateOutputPath)\$(Configuration)\$(TargetFramework)\ExtendedXmlSerializer.xml</DocumentationFile>
<!-- ReSharper disable once UnknownProperty -->
<DocumentationFile>$(BaseIntermediateOutputPath)\$(Configuration)\$(TargetFramework)\ExtendedXmlSerializer.xml</DocumentationFile>
<LangVersion>preview</LangVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class Contents : ISerializerExtension

/// <inheritdoc />
public IServiceRepository Get(IServiceRepository parameter)
=> parameter.RegisterConstructorDependency<IContents>((provider, info) => provider.Get<DeferredContents>())
=> parameter.RegisterConstructorDependency<IContents>((provider, _) => provider.Get<DeferredContents>())
.Register<IContents, RuntimeContents>()

.DecorateContentsWith<MemberedContents>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sealed class RuntimeSerializationExceptionMessage
= new RuntimeSerializationExceptionMessage();

RuntimeSerializationExceptionMessage() :
base(x => @"Parameterized Content is enabled on the container. By default, the type must satisfy the following rules if a public parameterless constructor is not found:
base(_ => @"Parameterized Content is enabled on the container. By default, the type must satisfy the following rules if a public parameterless constructor is not found:
- Each member must not already be marked as an explicit contract
- Must be a public fields / property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static TypeParts Copy(TypeParts parameter)
var array = parameter.GetArguments()
?.ToArray();
var result = new TypeParts(string.Concat(parameter.Name, Extension), parameter.Identifier,
array != null ? array.ToImmutableArray : (Func<ImmutableArray<TypeParts>>)null,
array != null ? array.ToImmutableArray : null,
parameter.Dimensions);
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ExtendedXmlSerializer/ExtensionModel/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public IServiceRepository Register<TService>(Func<IServiceProvider, TService> fa
public IServiceRepository RegisterFallback(Func<Type, bool> predicate, Func<Type, object> factory)
=>
new Services(_container,
_registry.RegisterFallback((type, s) => predicate(type),
_registry.RegisterFallback((type, _) => predicate(type),
request => factory(request.ServiceType)));

public IServiceRepository RegisterConstructorDependency<TDependency>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override IActivator Create(Type parameter)
var result = singleton != null
? activate
? new Activator(_activators.Build(parameter), singleton)
: (IActivator)new ReflectionModel.Activator(singleton.Self)
: new ReflectionModel.Activator(singleton.Self)
: activator();
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sealed class AllConstructorsExtension : ISerializerExtension
AllConstructorsExtension() {}

public IServiceRepository Get(IServiceRepository parameter)
=> parameter.Decorate<IConstructors>((provider, constructors) => new AllConstructors(constructors));
=> parameter.Decorate<IConstructors>((_, constructors) => new AllConstructors(constructors));

void ICommand<IServices>.Execute(IServices parameter) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TypeIdentity<T> : ITypeIdentity where T : Attribute
public TypeIdentity(Func<T, Key> identity) => _identity = identity;

public Key? Get(TypeInfo parameter)
=> parameter.IsDefined(typeof(T)) ? (Key?)_identity(parameter.GetCustomAttribute<T>()) : null;
=> parameter.IsDefined(typeof(T)) ? _identity(parameter.GetCustomAttribute<T>()) : null;
}

sealed class TypeIdentity : ITypeIdentity
Expand Down
2 changes: 1 addition & 1 deletion src/ExtendedXmlSerializer/ExtensionModel/Xml/XmlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ TypeParts Get(TypeParts parameter)
arguments.HasValue
? arguments.Value.Select(_selector)
.ToImmutableArray
: (Func<ImmutableArray<TypeParts>>)null, parameter.Dimensions);
: null, parameter.Dimensions);
return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ sealed class DefaultParameters : IParameterizedSource<ParameterInfo, Expression>

public Expression Get(ParameterInfo parameter)
=> parameter.IsDefined(typeof(ParamArrayAttribute))
? (Expression)Expression.NewArrayInit(parameter.ParameterType.GetElementType() ??
throw new
InvalidOperationException("Element Type not found."),
Initializers)
? Expression.NewArrayInit(parameter.ParameterType.GetElementType() ??
throw new
InvalidOperationException("Element Type not found."),
Initializers)
: Expression.Default(parameter.ParameterType);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ExtendedXmlSerializer/ReflectionModel/Defaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ static class Defaults
public static Func<ParameterExpression, Type, Expression> ExpressionZip { get; }
= (expression, type) => type.IsAssignableFrom(expression.Type)
? expression
: (Expression)Expression.Convert(expression, type);
: Expression.Convert(expression, type);
}
}
2 changes: 1 addition & 1 deletion test/.External/VweCore/Geometry/LeveledRectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public LeveledRectangle(Point2D firstPoint, Point2D secondPoint)

public bool IsEmpty => LowerLeft.Equals(UpperRight);

public Point2D Center => new Point2D(LowerLeft.X + (Width / 2), LowerLeft.Y + (Height / 2));
public Point2D Center => new Point2D(LowerLeft.X + Width / 2, LowerLeft.Y + Height / 2);

public bool Equals(LeveledRectangle other) => LowerLeft.Equals(other.LowerLeft) && UpperRight.Equals(other.UpperRight);

Expand Down
10 changes: 5 additions & 5 deletions test/.External/VweCore/Geometry/MathExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace VweCore.Geometry
{
public static class MathExtensions
{
public static double ToRadians(this double angleInDegrees) => (angleInDegrees * Math.PI) / 180.0;
public static double ToRadians(this double angleInDegrees) => angleInDegrees * Math.PI / 180.0;

public static double ToDegrees(this double angleInRadians) => (angleInRadians * 180) / Math.PI;
public static double ToDegrees(this double angleInRadians) => angleInRadians * 180 / Math.PI;

public static double Square(this double value) => value * value;

Expand All @@ -31,21 +31,21 @@ public static bool TryCalculateSlope(this Point2D point, Point2D other, out doub
return true;
}

public static double CalculateYIntercept(this Point2D point, double slope) => point.Y - (slope * point.X);
public static double CalculateYIntercept(this Point2D point, double slope) => point.Y - slope * point.X;

public static (double xDistance, double yDistance) CalculateDistances(this Point2D point, Point2D other) => (point.X - other.X, point.Y - other.Y);

public static double NormalizeAngleInDegrees(this double angleInDegrees)
{
if (angleInDegrees < 0.0)
return 360.0 + (angleInDegrees % -360.0);
return 360.0 + angleInDegrees % -360.0;
if (angleInDegrees < 360.0)
return angleInDegrees;

return angleInDegrees % 360.0;
}

public static double CalculateDotProduct(this Point2D point, Point2D other) => (point.X * other.X) + (point.Y * other.Y);
public static double CalculateDotProduct(this Point2D point, Point2D other) => point.X * other.X + point.Y * other.Y;

public static double CalculateDirectionAngle(this Point2D vector) =>
Math.Atan2(vector.Y, vector.X).ToDegrees();
Expand Down
4 changes: 2 additions & 2 deletions test/.External/VweCore/Geometry/Point2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public Point2D TranslateToOrigin(Point2D referencePoint) =>
public Point2D TranslateBackFromOrigin(Point2D referencePoint) =>
new Point2D(X + referencePoint.X, Y + referencePoint.Y);

public double CalculateRotatedXCoordinate(double angleInRadians) => (X * Math.Cos(angleInRadians)) - (Y * Math.Sin(angleInRadians));
public double CalculateRotatedXCoordinate(double angleInRadians) => X * Math.Cos(angleInRadians) - Y * Math.Sin(angleInRadians);

public double CalculateRotatedYCoordinate(double angleInRadians) => (X * Math.Sin(angleInRadians)) + (Y * Math.Cos(angleInRadians));
public double CalculateRotatedYCoordinate(double angleInRadians) => X * Math.Sin(angleInRadians) + Y * Math.Cos(angleInRadians);

public static bool operator !=(Point2D left, Point2D right) => !left.Equals(right);

Expand Down
6 changes: 3 additions & 3 deletions test/.External/VweCore/Geometry/SlopeInterceptEquation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override int GetHashCode()

public static bool operator !=(SlopeInterceptEquation left, SlopeInterceptEquation right) => !left.Equals(right);

public double CalculateY(double x) => (x * Slope) + YIntercept;
public double CalculateY(double x) => x * Slope + YIntercept;

public bool ContainsPoint(Point2D point) => CalculateY(point.X).IsApproximately(point.Y);

Expand Down Expand Up @@ -73,8 +73,8 @@ public Point2D GetPointByDistance(double x, double distance, AbscissaDirection d
var x2 = x + xDistance;

var pointX = direction == AbscissaDirection.LeftToRight
? (x1.IsGreaterThanOrApproximatelyEqualTo(x) ? x1 : x2)
: (x1.IsLessThanOrApproximatelyEqualTo(x) ? x1 : x2);
? x1.IsGreaterThanOrApproximatelyEqualTo(x) ? x1 : x2
: x1.IsLessThanOrApproximatelyEqualTo(x) ? x1 : x2;

return new Point2D(pointX, CalculateY(pointX));
}
Expand Down
4 changes: 2 additions & 2 deletions test/.External/VweCore/Node.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Light.GuardClauses;
using System;
using System.Collections.Generic;
using Light.GuardClauses;
using VweCore.Geometry;
using VweCore.Translations;

Expand Down Expand Up @@ -43,7 +43,7 @@ public NodeLink AddLinkedNode(Node node, int nodeLinkId, bool isBidirectional =
Node2 = node,
Direction = isBidirectional ? NodeLinkDirection.Bidirectional : NodeLinkDirection.FromNode1ToNode2,
DrivingDirectionFromNode1 = NodeLinkDrivingDirection.Straight,
DrivingDirectionFromNode2 = isBidirectional ? NodeLinkDrivingDirection.Straight : (NodeLinkDrivingDirection?)null
DrivingDirectionFromNode2 = isBidirectional ? NodeLinkDrivingDirection.Straight : null
};
NodeLinks.Add(nodeLink);
node.NodeLinks.Add(nodeLink);
Expand Down
Loading

0 comments on commit 5b777b4

Please sign in to comment.