Skip to content

Commit

Permalink
Merge pull request #52 from pyrocumulus/maintenance
Browse files Browse the repository at this point in the history
Maintenance. 

Package updates, code cleanup and switching of analyzer package.
  • Loading branch information
pyrocumulus authored Mar 11, 2021
2 parents 3e497c1 + 5890c5a commit cbea860
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 35 deletions.
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "nuget"
directory: "/src/PVOutput.Net/"
schedule:
interval: "daily"

- package-ecosystem: "nuget"
directory: "/tests/PVOutput.Net.Tests/"
schedule:
interval: "daily"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Updated

- Updated `Microsoft.Extensions.DependencyInjection.Abstractions` from `v3.1.7` to `v5.0.0` [#52](https://github.com/pyrocumulus/pvoutput.net/pull/52)
- Updated `Microsoft.Extensions.Logging.Abstractions` from `v3.1.7` to `v5.0.0` [#52](https://github.com/pyrocumulus/pvoutput.net/pull/52)
- Migrated analyzers `Microsoft.CodeAnalysis.FxCopAnalyzers` to `Microsoft.CodeAnalysis.NetAnalyzers` `v5.0.3` [#52](https://github.com/pyrocumulus/pvoutput.net/pull/52)

### Fixed

- **BREAKING**: Some methods will now return an `Orientation` enumeration value instead of a string representation [#49](https://github.com/pyrocumulus/pvoutput.net/pull/49)
- **BREAKING**: Some methods will now return a `Shade` enumeration value instead of a string representation [#50](https://github.com/pyrocumulus/pvoutput.net/pull/50)
- **BREAKING**: Marked `InstallDate` and `ArrayTilt` aspects as nullable, as they are optional in PVOutput [#50](https://github.com/pyrocumulus/pvoutput.net/pull/50)
- Marked assembly as `[CLSCompliant]` [#52](https://github.com/pyrocumulus/pvoutput.net/pull/52)

## [0.8.1] - 2020-11-07

Expand Down
13 changes: 13 additions & 0 deletions src/PVOutput.Net/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

[assembly: CLSCompliant(true)]
namespace PVOutput.Net
{
internal class AssemblyInfo
{
public AssemblyInfo()
{

}
}
}
4 changes: 2 additions & 2 deletions src/PVOutput.Net/Objects/Core/FormatHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal static string GetEnumerationDescription<TEnumType>(this TEnumType enume
throw new ArgumentException("EnumerationValue must be of Enum type", nameof(enumerationValue));
}

string name = Enum.GetName(type, enumerationValue);
var name = Enum.GetName(type, enumerationValue);
if (name != null)
{
FieldInfo field = type.GetField(name);
Expand All @@ -98,7 +98,7 @@ internal static string GetEnumerationDescription<TEnumType>(this TEnumType enume

public static TEnumType DescriptionToEnumValue<TEnumType>(this string enumerationDescription) where TEnumType : struct
{
var type = typeof(TEnumType);
Type type = typeof(TEnumType);

if (!type.IsEnum)
{
Expand Down
4 changes: 2 additions & 2 deletions src/PVOutput.Net/Objects/ExtendedDataConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ internal ExtendedDataConfiguration(string label, string unit)
/// <summary>
/// Indicates if the current object is equal to another object of the same type
/// </summary>
/// <param name="other">Other object to compare to</param>
/// <param name="obj">Other object to compare to</param>
/// <returns>True if both objects are equal, false otherwise</returns>
public override bool Equals(object other) => other is ExtendedDataConfiguration element && Equals(element);
public override bool Equals(object obj) => obj is ExtendedDataConfiguration element && Equals(element);

/// <summary>
/// Indicates if the current object is equal to another object of the same type
Expand Down
38 changes: 19 additions & 19 deletions src/PVOutput.Net/Objects/Factories/StringFactoryContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ namespace PVOutput.Net.Objects.Factories
{
internal static class StringFactoryContainer
{
private static readonly Dictionary<Type, object> _readerFactories = new Dictionary<Type, object>();
private static Dictionary<Type, object> ReaderFactories { get; } = new Dictionary<Type, object>();

static StringFactoryContainer()
{
_readerFactories.Add(typeof(IOutput), new OutputFactory());
_readerFactories.Add(typeof(ITeamOutput), new TeamOutputFactory());
_readerFactories.Add(typeof(IAggregatedOutput), new AggregatedOutputFactory());
_readerFactories.Add(typeof(ISystem), new SystemFactory());
_readerFactories.Add(typeof(IStatus), new StatusFactory());
_readerFactories.Add(typeof(IStatusHistory), new StatusHistoryFactory());
_readerFactories.Add(typeof(IDayStatistics), new DayStatisticsFactory());
_readerFactories.Add(typeof(IBatchStatusPostResult), new BatchStatusPostResultFactory());
_readerFactories.Add(typeof(IStatistic), new StatisticFactory());
_readerFactories.Add(typeof(IMissing), new MissingFactory());
_readerFactories.Add(typeof(ITeam), new TeamFactory());
_readerFactories.Add(typeof(IExtended), new ExtendedFactory());
_readerFactories.Add(typeof(IFavourite), new FavouriteFactory());
_readerFactories.Add(typeof(IInsolation), new InsolationFactory());
_readerFactories.Add(typeof(ISupply), new SupplyFactory());
_readerFactories.Add(typeof(ISystemSearchResult), new SystemSearchResultFactory());
ReaderFactories.Add(typeof(IOutput), new OutputFactory());
ReaderFactories.Add(typeof(ITeamOutput), new TeamOutputFactory());
ReaderFactories.Add(typeof(IAggregatedOutput), new AggregatedOutputFactory());
ReaderFactories.Add(typeof(ISystem), new SystemFactory());
ReaderFactories.Add(typeof(IStatus), new StatusFactory());
ReaderFactories.Add(typeof(IStatusHistory), new StatusHistoryFactory());
ReaderFactories.Add(typeof(IDayStatistics), new DayStatisticsFactory());
ReaderFactories.Add(typeof(IBatchStatusPostResult), new BatchStatusPostResultFactory());
ReaderFactories.Add(typeof(IStatistic), new StatisticFactory());
ReaderFactories.Add(typeof(IMissing), new MissingFactory());
ReaderFactories.Add(typeof(ITeam), new TeamFactory());
ReaderFactories.Add(typeof(IExtended), new ExtendedFactory());
ReaderFactories.Add(typeof(IFavourite), new FavouriteFactory());
ReaderFactories.Add(typeof(IInsolation), new InsolationFactory());
ReaderFactories.Add(typeof(ISupply), new SupplyFactory());
ReaderFactories.Add(typeof(ISystemSearchResult), new SystemSearchResultFactory());
}

private static object GetObjectStringFactory<TReturnType>()
{
Type type = typeof(TReturnType);
if (!_readerFactories.ContainsKey(type))
if (!ReaderFactories.ContainsKey(type))
{
throw new InvalidOperationException($"Factory for {type} is not known");
}

return _readerFactories[type];
return ReaderFactories[type];
}

public static IObjectStringReader<TReturnType> CreateObjectReader<TReturnType>()
Expand Down
4 changes: 2 additions & 2 deletions src/PVOutput.Net/Objects/PVCoordinate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public override string ToString()
/// <summary>
/// Indicates if the current object is equal to another object of the same type
/// </summary>
/// <param name="other">Other object to compare to</param>
/// <param name="obj">Other object to compare to</param>
/// <returns>True if both objects are equal, false otherwise</returns>
public override bool Equals(object other) => other is PVCoordinate coordinate && Equals(coordinate);
public override bool Equals(object obj) => obj is PVCoordinate coordinate && Equals(coordinate);

/// <summary>
/// Indicates if the current object is equal to another object of the same type
Expand Down
10 changes: 7 additions & 3 deletions src/PVOutput.Net/PVOutput.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@ https://github.com/pyrocumulus/pvoutput.net/blob/master/CHANGELOG.md</PackageRel
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dawn.Guard" Version="1.12.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="Tavis.UriTemplates" Version="1.1.1" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions tests/PVOutput.Net.Tests/Client/PVOutputClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@ public void Create_ClientWithOptionsAndLogger_CreatesClientWithLogger()
Assert.That(client.Logger, Is.Not.EqualTo(NullLogger<PVOutputClient>.Instance));
});
}

[Test]
public void Create_AssemblyInfo_CreatesAssemblyInfo()
{
_ = new AssemblyInfo(); // For code coverage
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NUnit.Framework;
using PVOutput.Net.Enums;
using PVOutput.Net.Objects;
using PVOutput.Net.Responses;
using PVOutput.Net.Tests.Utils;
using RichardSzalay.MockHttp;

Expand All @@ -21,7 +22,7 @@ public async Task FavouriteService_GetSingle()
testProvider.ExpectUriFromBase(GETFAVOURITE_URL)
.RespondPlainText(FAVOURITE_RESPONSE_SINGLE);

var response = await client.Favourite.GetFavouritesAsync();
PVOutputArrayResponse<IFavourite> response = await client.Favourite.GetFavouritesAsync();
testProvider.VerifyNoOutstandingExpectation();
AssertStandardResponse(response);
}
Expand All @@ -35,7 +36,7 @@ public async Task FavouriteReader_ForResponse_CreatesCorrectObjects()
{
IEnumerable<IFavourite> result = await TestUtility.ExecuteArrayReaderByTypeAsync<IFavourite>(FAVOURITE_RESPONSE_SINGLE);

var favourite = result.First();
IFavourite favourite = result.First();
Assert.Multiple(() => {
Assert.That(favourite.SystemId, Is.EqualTo(21));
Assert.That(favourite.SystemName, Is.EqualTo("PVOutput Demo"));
Expand Down
11 changes: 6 additions & 5 deletions tests/PVOutput.Net.Tests/Modules/System/SystemServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Collections.Generic;
using System;
using System.Linq;
using PVOutput.Net.Responses;

namespace PVOutput.Net.Tests.Modules.System
{
Expand All @@ -24,7 +25,7 @@ public async Task SystemService_GetOwnSystem_CallsCorrectUri()
testProvider.ExpectUriFromBase(GETSYSTEM_URL)
.RespondPlainText(SYSTEM_RESPONSE_EXTENDED);

var response = await client.System.GetOwnSystemAsync();
PVOutputResponse<ISystem> response = await client.System.GetOwnSystemAsync();
testProvider.VerifyNoOutstandingExpectation();
AssertStandardResponse(response);
}
Expand All @@ -38,7 +39,7 @@ public async Task SystemService_GetOtherSystem_CallsCorrectUri()
.WithQueryString("sid1=54321")
.RespondPlainText(SYSTEM_RESPONSE_EXTENDED);

var response = await client.System.GetOtherSystemAsync(54321);
PVOutputResponse<ISystem> response = await client.System.GetOtherSystemAsync(54321);
testProvider.VerifyNoOutstandingExpectation();
AssertStandardResponse(response);
}
Expand All @@ -52,7 +53,7 @@ public async Task SystemService_PostSystem_CallsCorrectUri()
.WithExactQueryString("sid=54321&name=New%20name&v7l=New%20power&v7u=W")
.RespondPlainText("");

var response = await client.System.PostSystem(54321, "New name", new List<IExtendedDataDefinition>() { new ExtendedDataDefinition() { Label = "New power", Unit = "W" } });
PVOutputBasicResponse response = await client.System.PostSystem(54321, "New name", new List<IExtendedDataDefinition>() { new ExtendedDataDefinition() { Label = "New power", Unit = "W" } });
testProvider.VerifyNoOutstandingExpectation();
AssertStandardResponse(response);
}
Expand Down Expand Up @@ -195,8 +196,8 @@ public async Task SystemReader_ForResponseWithoutEstimates_CreatesCorrectObject(
public async Task SystemReader_ForResponseWithIncompleteExtendedProperties_CreatesCorrectObject()
{
ISystem result = await TestUtility.ExecuteObjectReaderByTypeAsync<ISystem>(SYSTEM_RESPONSE_WITH_MINIMALEXTENDEDDATA);
var secondDataConfig = result.ExtendedDataConfig[1];
var thirdDataConfig = result.ExtendedDataConfig[2];
ExtendedDataConfiguration secondDataConfig = result.ExtendedDataConfig[1];
ExtendedDataConfiguration thirdDataConfig = result.ExtendedDataConfig[2];

Assert.Multiple(() =>
{
Expand Down

0 comments on commit cbea860

Please sign in to comment.