Skip to content

Commit

Permalink
Remove unwanted checks and add workarounds for testing on windows-onl…
Browse files Browse the repository at this point in the history
…y .net versions.
  • Loading branch information
aloneguid committed Aug 2, 2022
1 parent 7f8bb61 commit ca6019b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Release

env:
v: '5.1.0'
v: '5.1.1'
av: '5.0.0'
pv: '5.1.0'
pv: '5.1.1'

on:
push:
Expand Down
6 changes: 6 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,12 @@ will correspond to the following JSON file:
}
```

## Using With

### Azure Functions

Azure function [configuration](https://docs.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings?tabs=portal) can be set in portal or settings file when developing locally. This is just a pure magic and they are all exposed as environment variables at the end of the day. `.UseEnvironmentVariables()` will allow to read those values.

## Sponsorship

This framework is free and can be used for free, open source and commercial applications. Config.Net (all code, NuGets and binaries) are under the [MIT License (MIT)](https://github.com/aloneguid/config/blob/master/LICENSE). It's battle-tested and used by many awesome people and organisations. So hit the magic ⭐️ button, we appreciate it!!! 🙏 Thx!
Expand Down
16 changes: 8 additions & 8 deletions src/Config.Net.Tests/DefaultValuesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IFixtureSettings
[DefaultValue("not set")]
string UnitTestName { get; set; }

[DefaultValue((sbyte)10)]
[Option(DefaultValue = (sbyte)10)]
sbyte NumberOfYears { get; set; }

[DefaultValue((short)1000)]
Expand All @@ -31,13 +31,13 @@ public interface IFixtureSettings
[DefaultValue((byte)24)]
byte HoursOfDay { get; set; }

[DefaultValue((ushort)1440)]
[Option(DefaultValue = (ushort)1440)]
ushort MinutesOfDay { get; set; }

[DefaultValue((uint)86400)]
[Option(DefaultValue = (uint)86400)]
uint SecondsOfDay { get; set; }

[DefaultValue((ulong)86400000000)]
[Option(DefaultValue = (ulong)86400000000)]
ulong MicroSecondsOfDay { get; set; }

[DefaultValue("Japan Denmark Australia")]
Expand Down Expand Up @@ -81,7 +81,7 @@ public void Read_DefaultString_Reads()
[Fact]
public void Read_DefaultSByte_Reads()
{
CheckProperty(nameof(IFixtureSettings.NumberOfYears));
CheckProperty(nameof(IFixtureSettings.NumberOfYears), (sbyte)10);
}

[Fact]
Expand Down Expand Up @@ -111,19 +111,19 @@ public void Read_DefaultByte_Reads()
[Fact]
public void Read_DefaultUShort_Reads()
{
CheckProperty(nameof(IFixtureSettings.MinutesOfDay));
CheckProperty(nameof(IFixtureSettings.MinutesOfDay), (ushort)1440);
}

[Fact]
public void Read_DefaultUInt_Reads()
{
CheckProperty(nameof(IFixtureSettings.SecondsOfDay));
CheckProperty(nameof(IFixtureSettings.SecondsOfDay), (uint)86400);
}

[Fact]
public void Read_DefaultULong_Reads()
{
CheckProperty(nameof(IFixtureSettings.MicroSecondsOfDay));
CheckProperty(nameof(IFixtureSettings.MicroSecondsOfDay), (ulong)86400000000);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions src/Config.Net/Core/Box/BoxFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ private static void AddAttributes(ResultBox box, ValueHandler valueHandler, para
if (defaultValue != null)
{
//validate that types for default value match
Type? dvt = defaultValue?.GetType();
Type dvt = defaultValue.GetType();

if (dvt != box.ResultType && dvt != typeof(string))
{
throw new InvalidCastException($"Default value for option {box.Name} is of type {dvt?.FullName} whereas the property has type {box.Name}. To fix this, either set default value to type {box.ResultType.FullName} or a string parseable to the target type.");
throw new InvalidCastException($"Default value for option {box.Name} is of type {dvt.FullName} whereas the property has type {box.ResultType.FullName}. To fix this, either set default value to type {box.ResultType.FullName} or a string parseable to the target type.");
}

if (box.ResultType != typeof(string) && dvt == typeof(string))
Expand Down

0 comments on commit ca6019b

Please sign in to comment.