Skip to content

Commit

Permalink
Merge pull request #108 from pfpack/release/v1.99.0-preview.2.0.0
Browse files Browse the repository at this point in the history
release/v2.0.0-preview.1.0.1
  • Loading branch information
andreise authored Jan 19, 2022
2 parents 7766582 + 0f9270e commit b1baade
Show file tree
Hide file tree
Showing 208 changed files with 3,507 additions and 1,307 deletions.
20 changes: 15 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# User-specific files
*.rsuser
Expand Down Expand Up @@ -206,9 +206,6 @@ PublishScripts/
*.nuget.props
*.nuget.targets

# Nuget personal access tokens and Credentials
# nuget.config

# Microsoft Azure Build Output
csx/
*.build.csdef
Expand Down Expand Up @@ -297,6 +294,17 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp

# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp

# Visual Studio 6 technical files
*.ncb
*.aps

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
Expand Down Expand Up @@ -353,6 +361,9 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/

# Visual Studio History (VSHistory) files
.vshistory/

# BeatPulse healthcheck temp database
healthchecksdb

Expand Down Expand Up @@ -384,5 +395,4 @@ FodyWeavers.xsd
*.msp

# JetBrains Rider
.idea/
*.sln.iml
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2021 Andrei Sergeev, Pavel Moskovoy
Copyright (c) 2020-2022 Andrei Sergeev, Pavel Moskovoy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 11 additions & 0 deletions docs/core-taggeds-result/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# PrimeFuncPack Core.Result

PrimeFuncPack Core.Result is a core library for .NET consisting of Result monad targeted for use in functional programming.
The Core.Result is shipped as a part of PrimeFuncPack Core - a functional programming framework for .NET

PrimeFuncPack Core is a functional programming pack for .NET consisting of the fundamentals:
- Optional and Result monads, Failure type, Tagged Union, and Unit type;
- Functional interfaces (Single Abstract Method interfaces);
- as well as extensions such as the Optional Linq, the SAM interfaces factories, etc.

The Pack supports both asynchronous and synchronous programming models.
11 changes: 11 additions & 0 deletions docs/core-taggeds-union/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# PrimeFuncPack Core.TaggedUnion

PrimeFuncPack Core.TaggedUnion is a core library for .NET consisting of Tagged Union targeted for use in functional programming.
The Core.TaggedUnion is shipped as a part of PrimeFuncPack Core - a functional programming framework for .NET

PrimeFuncPack Core is a functional programming pack for .NET consisting of the fundamentals:
- Optional and Result monads, Failure type, Tagged Union, and Unit type;
- Functional interfaces (Single Abstract Method interfaces);
- as well as extensions such as the Optional Linq, the SAM interfaces factories, etc.

The Pack supports both asynchronous and synchronous programming models.
11 changes: 11 additions & 0 deletions docs/core-taggeds/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# PrimeFuncPack Core.Taggeds

PrimeFuncPack Core.Taggeds is a core pack for .NET consisting of fundamental tagged types targeted for use in functional programming: Optional and Result monads, Tagged Union, as well as the convert extensions.
The Core.Taggeds is shipped as a part of PrimeFuncPack Core - a functional programming framework for .NET

PrimeFuncPack Core is a functional programming pack for .NET consisting of the fundamentals:
- Optional and Result monads, Failure type, Tagged Union, and Unit type;
- Functional interfaces (Single Abstract Method interfaces);
- as well as extensions such as the Optional Linq, the SAM interfaces factories, etc.

The Pack supports both asynchronous and synchronous programming models.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Copyright>Copyright © 2020-2022 Andrei Sergeev, Pavel Moskovoy</Copyright>
<RootNamespace>PrimeFuncPack.Core.Tests</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Failure.Tests</AssemblyName>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ partial struct Failure<TFailureCode>
public Failure<TResultFailureCode> MapFailureCode<TResultFailureCode>(
Func<TFailureCode, TResultFailureCode> mapFailureCode)
where TResultFailureCode : struct
{
_ = mapFailureCode ?? throw new ArgumentNullException(nameof(mapFailureCode));

return new(
failureCode: mapFailureCode.Invoke(FailureCode),
failureMessage: FailureMessage);
}
=>
InnerMapFailureCode(
mapFailureCode ?? throw new ArgumentNullException(nameof(mapFailureCode)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ partial struct Failure<TFailureCode>
public override string ToString()
=>
Invariant(
$"Failure[{typeof(TFailureCode)}]:{{ \"{nameof(FailureCode)}\": {FailureCode}, \"{nameof(FailureMessage)}\": \"{FailureMessage}\" }}");
$"Failure[{typeof(TFailureCode)}]:{{ \"FailureCode\": {FailureCode}, \"FailureMessage\": \"{FailureMessage}\" }}");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Runtime.CompilerServices;

namespace System;

partial struct Failure<TFailureCode>
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private Failure<TResultFailureCode> InnerMapFailureCode<TResultFailureCode>(
Func<TFailureCode, TResultFailureCode> mapFailureCode)
where TResultFailureCode : struct
=>
new(
failureCode: mapFailureCode.Invoke(FailureCode),
failureMessage: FailureMessage);
}
6 changes: 3 additions & 3 deletions src/core-taggeds-failure/Failure/Failure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<RepositoryUrl>https://github.com/pfpack/pfpack-core-taggeds</RepositoryUrl>
<Company>pfpack</Company>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Copyright>Copyright © 2020-2022 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Description>PrimeFuncPack Core.Failure is a core library for .NET consisting of Failure type targeted for use in functional programming.</Description>
<RootNamespace>System</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Failure</AssemblyName>
<Version>2.0.0-preview.1.0.0</Version>
<Version>2.0.0-preview.1.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.0" />
<PackageReference Include="PrimeFuncPack.Core.Unit" Version="2.1.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Globalization;
using static PrimeFuncPack.UnitTest.TestData;

Expand All @@ -8,38 +9,38 @@ namespace PrimeFuncPack.Core.Tests;
partial class OptionalTest
{
[Test]
public void ToString_SourceIsAbsent_ExpectAbsentString()
public void ToString_SourceIsAbsent()
{
var source = Optional<StubType>.Absent;

var actual = source.ToString();

var expected = string.Format(
CultureInfo.InvariantCulture,
"Optional.Absent[{0}]:()",
"Optional[{0}]:Absent:()",
typeof(StubType));

Assert.AreEqual(expected, actual);
}

[Test]
public void ToString_SourceIsPresentAndValueIsNull_ExpectPresentEmptyString()
public void ToString_SourceIsPresentAndValueIsNull()
{
var source = Optional<StubType?>.Present(null);

var actual = source.ToString();

var expected = string.Format(
CultureInfo.InvariantCulture,
"Optional.Present[{0}]:{1}",
"Optional[{0}]:Present:{1}",
typeof(StubType),
string.Empty);

Assert.AreEqual(expected, actual);
}

[Test]
public void ToString_SourceIsPresentAndValueToStringIsNull_ExpectPresentEmptyString()
public void ToString_SourceIsPresentAndValueToStringIsNull()
{
var sourceValue = new StubType(null);
var source = Optional<StubType>.Present(sourceValue);
Expand All @@ -48,14 +49,15 @@ public void ToString_SourceIsPresentAndValueToStringIsNull_ExpectPresentEmptyStr

var expected = string.Format(
CultureInfo.InvariantCulture,
"Optional.Present[{0}]:{1}",
"Optional[{0}]:Present:{1}",
typeof(StubType),
string.Empty);

Assert.AreEqual(expected, actual);
}

[Test]
[TestCase(null)]
[TestCase(EmptyString)]
[TestCase(TabString)]
[TestCase(TwoTabsString)]
Expand All @@ -64,8 +66,8 @@ public void ToString_SourceIsPresentAndValueToStringIsNull_ExpectPresentEmptyStr
[TestCase(ThreeWhiteSpacesString)]
[TestCase(MixedWhiteSpacesString)]
[TestCase(SomeString)]
public void ToString_SourceIsPresentAndValueToStringIsNotNull_ExpectSourceValueToStringResult(
string sourceValueToStringResult)
public void ToString_SourceIsPresent_ValueToString_Common(
string? sourceValueToStringResult)
{
var sourceValue = new StubType(sourceValueToStringResult);
var source = Optional<StubType>.Present(sourceValue);
Expand All @@ -74,14 +76,13 @@ public void ToString_SourceIsPresentAndValueToStringIsNotNull_ExpectSourceValueT

var expected = string.Format(
CultureInfo.InvariantCulture,
"Optional.Present[{0}]:{1}",
"Optional[{0}]:Present:{1}",
typeof(StubType),
sourceValueToStringResult);

Assert.AreEqual(expected, actual);
}

// TODO: Add test case source including decimal with point
[Test]
[TestCase(null)]
[TestCase(EmptyString)]
Expand All @@ -95,7 +96,7 @@ public void ToString_SourceIsPresentAndValueToStringIsNotNull_ExpectSourceValueT
[TestCase(MinusOne)]
[TestCase(Zero)]
[TestCase(One)]
public void ToString_Common(
public void ToString_SourceIsPresent_Common(
object? sourceValue)
{
var source = Optional<object?>.Present(sourceValue);
Expand All @@ -104,10 +105,35 @@ public void ToString_Common(

var expected = string.Format(
CultureInfo.InvariantCulture,
"Optional.Present[{0}]:{1}",
"Optional[{0}]:Present:{1}",
typeof(object),
sourceValue);

Assert.AreEqual(expected, actual);
}

[Test]
[TestCaseSource(nameof(ToString_SourceIsPresent_DecimalPoint_TestCaseSource))]
public void ToString_SourceIsPresent_DecimalPoint(
decimal sourceValue, string expectedDecimalSubstr)
{
var source = Optional<decimal>.Present(sourceValue);

var actual = source.ToString();

var expected = string.Format(
CultureInfo.InvariantCulture,
"Optional[{0}]:Present:{1}",
typeof(decimal),
expectedDecimalSubstr);

Assert.AreEqual(expected, actual);
}

private static IEnumerable<object[]> ToString_SourceIsPresent_DecimalPoint_TestCaseSource()
{
yield return new object[] { -1.1m, "-1.1" };
yield return new object[] { 0.0m, "0.0" };
yield return new object[] { 1.1m, "1.1" };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2020-2021 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Copyright>Copyright © 2020-2022 Andrei Sergeev, Pavel Moskovoy</Copyright>
<RootNamespace>PrimeFuncPack.Core.Tests</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Optional.Tests</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="3.0.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Moq" Version="1.0.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace System;
using static System.FormattableString;
using static System.FormattableString;

namespace System;

partial struct Absent<T>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

partial struct Absent<T>
{
// TODO: Uncomment when Absent<T> becomes public
//public static readonly Absent<T> Value;
public static readonly Absent<T> Value;

// TODO: Remove the static constructor when Absent<T> becomes public (it is a workaround for the internal Absent<T>)
static Absent() => Value = default;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable CA1822 // Mark members as static

namespace System;

partial struct Absent<T>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
namespace System;
using static System.FormattableString;

namespace System;

partial struct Absent<T>
{
public override string ToString()
=>
InternalToString<T>.Absent();
Invariant($"Absent[{typeof(T)}]:()");
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit b1baade

Please sign in to comment.