Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/scripts/validate-csharp-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ if [[ ${#symbol_packages[@]} -ne 0 ]]; then
exit 1
fi

package_contents=$(unzip -Z1 "${packages[0]}")
for expected_file in README.md icon.png lib/net8.0/Platform.Interfaces.dll; do
if ! unzip -Z1 "${packages[0]}" | grep -Fxq "$expected_file"; then
if ! grep -Fxq "$expected_file" <<< "$package_contents"; then
echo "${packages[0]} is missing $expected_file." >&2
exit 1
fi
Expand Down
19 changes: 12 additions & 7 deletions cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,22 @@ namespace Platform::Interfaces::Tests {
}
}

TEST(CompileTests, CriterionMatcher) {
struct EmptyCriterionMatcher : public ICriterionMatcher<int> {
bool IsMatched(int) { return {}; }
TEST(CompileTests, Matcher) {
struct MinimumMatcher : public IMatcher<int> {
int minimum;
explicit MinimumMatcher(int value) : minimum(value) {}
bool IsMatched(int candidate) override { return candidate >= minimum; }
};
static_assert(CCriterionMatcher<EmptyCriterionMatcher, int>);
static_assert(CMatcher<MinimumMatcher, int>);

{
CCriterionMatcher<int> auto criterionMatcher = EmptyCriterionMatcher{};
CMatcher<int> auto matcher = MinimumMatcher{10};
IMatcher<int>& interface = matcher;

ASSERT_TRUE((CCriterionMatcher<EmptyCriterionMatcher, int>));
ASSERT_TRUE((CCriterionMatcher<EmptyCriterionMatcher, float>));
ASSERT_TRUE((CMatcher<MinimumMatcher, int>));
ASSERT_TRUE((CMatcher<MinimumMatcher, float>));
ASSERT_FALSE(interface.IsMatched(9));
ASSERT_TRUE(interface.IsMatched(10));
}
}

Expand Down
10 changes: 0 additions & 10 deletions cpp/Platform.Interfaces/CCriterionMatcher.h

This file was deleted.

10 changes: 10 additions & 0 deletions cpp/Platform.Interfaces/CMatcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <concepts>

namespace Platform::Interfaces {
template <typename TSelf, typename TCandidate>
concept CMatcher = requires(TSelf self, TCandidate candidate) {
{ self.IsMatched(candidate) } -> std::same_as<bool>;
};
} // namespace Platform::Interfaces
13 changes: 0 additions & 13 deletions cpp/Platform.Interfaces/ICriterionMatcher.h

This file was deleted.

13 changes: 13 additions & 0 deletions cpp/Platform.Interfaces/IMatcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

namespace Platform::Interfaces {
template <typename...>
struct IMatcher;

template <typename TCandidate>
struct IMatcher<TCandidate> {
virtual bool IsMatched(TCandidate candidate) = 0;

virtual ~IMatcher() = default;
};
} // namespace Platform::Interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<title>LinksPlatform's Platform.Interfaces Template Library</title>
<summary>LinksPlatform's Platform.Interfaces is a Template Library what contains common concepts templates.</summary>
<description>LinksPlatform's Platform.Interfaces is a Template Library what contains set of C++ concepts templates. Use Platform.Interfaces.h file to include the library.</description>
<releaseNotes>Test release for automatic deploy system.</releaseNotes>
<version>0.3.43</version>
<releaseNotes>Breaking change: rename ICriterionMatcher to IMatcher and CCriterionMatcher to CMatcher. Update header includes and references.</releaseNotes>
<version>0.4.0</version>
<authors>konard, uselessgoddess, Mitron57</authors>
<owners>konard, uselessgoddess, Mitron57</owners>
<copyright>konard, uselessgoddess, Mitron57</copyright>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
<ItemGroup>
<ClInclude Include="ICounter[TResult, TArgument].h" />
<ClInclude Include="ICounter[TResult].h" />
<ClInclude Include="ICriterionMatcher.h" />
<ClInclude Include="IMatcher.h" />
<ClInclude Include="IFactory.h" />
<ClInclude Include="IProperties.h" />
<ClInclude Include="IProperty.h" />
Expand All @@ -157,4 +157,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ClInclude Include="ICounter[TResult].h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ICriterionMatcher.h">
<ClInclude Include="IMatcher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="IFactory.h">
Expand Down Expand Up @@ -49,4 +49,4 @@
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions cpp/Platform.Interfaces/Platform.Interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "CSet.h"
#include "CDictionary.h"
#include "CCounter.h"
#include "CCriterionMatcher.h"
#include "CMatcher.h"
#include "CFactory.h"
#include "CLink.h"
#include "CLinkAddress.h"
Expand All @@ -20,7 +20,7 @@

#include "ICounter[TResult, TArgument].h"
#include "ICounter[TResult].h"
#include "ICriterionMatcher.h"
#include "IMatcher.h"
#include "IFactory.h"
#include "IProperties.h"
#include "IProperty.h"
Expand Down
16 changes: 15 additions & 1 deletion csharp/Platform.Interfaces.Tests/InterfacesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void BuildTest()
{
ICounter<int, int>? c1 = null;
ICounter<int>? c2 = null;
ICriterionMatcher<int>? cm1 = null;
IMatcher<int>? cm1 = null;
IFactory<int>? f1 = null;
IProperties<int, int, int>? p1 = null;
IProperty<int, int>? p2 = null;
Expand All @@ -32,6 +32,15 @@ public static void BuildTest()
Assert.Null(s2);
}

[Fact]
public static void MatcherTestsCandidate()
{
IMatcher<int> matcher = new MinimumMatcher(10);

Assert.False(matcher.IsMatched(9));
Assert.True(matcher.IsMatched(10));
}

[Fact]
public static void AssemblyContainsEmbeddedPortablePdb()
{
Expand All @@ -42,5 +51,10 @@ public static void AssemblyContainsEmbeddedPortablePdb()
peReader.ReadDebugDirectory(),
entry => entry.Type == DebugDirectoryEntryType.EmbeddedPortablePdb);
}

private sealed class MinimumMatcher(int minimum) : IMatcher<int>
{
public bool IsMatched(int candidate) => candidate >= minimum;
}
}
}
27 changes: 0 additions & 27 deletions csharp/Platform.Interfaces/ICriterionMatcher.cs

This file was deleted.

27 changes: 27 additions & 0 deletions csharp/Platform.Interfaces/IMatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Platform.Interfaces
{
/// <summary>
/// <para>Defines a matcher that determines whether a candidate satisfies its matching rule.</para>
/// <para>Определяет объект, который проверяет, соответствует ли кандидат правилу сопоставления.</para>
/// </summary>
/// <typeparam name="TCandidate">
/// <para>Type of the value being tested for a match.</para>
/// <para>Тип значения, проверяемого на соответствие.</para>
/// </typeparam>
public interface IMatcher<in TCandidate>
{
/// <summary>
/// <para>Determines whether the candidate satisfies the matching rule.</para>
/// <para>Определяет, соответствует ли кандидат правилу сопоставления.</para>
/// </summary>
/// <param name="candidate">
/// <para>The value to test.</para>
/// <para>Проверяемое значение.</para>
/// </param>
/// <returns>
/// <para>Whether the candidate satisfies the matching rule.</para>
/// <para>Соответствует ли кандидат правилу сопоставления.</para>
/// </returns>
bool IsMatched(TCandidate candidate);
}
}
6 changes: 3 additions & 3 deletions csharp/Platform.Interfaces/Platform.Interfaces.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<Description>LinksPlatform's Platform.Interfaces Class Library</Description>
<Copyright>Konstantin Diachenko</Copyright>
<AssemblyTitle>Platform.Interfaces</AssemblyTitle>
<VersionPrefix>0.5.3</VersionPrefix>
<VersionPrefix>0.6.0</VersionPrefix>
<Authors>Konstantin Diachenko</Authors>
<TargetFramework>net8</TargetFramework>
<AssemblyName>Platform.Interfaces</AssemblyName>
<PackageId>Platform.Interfaces</PackageId>
<PackageTags>LinksPlatform;Interfaces;ICounter;ICriterionMatcher;IFactory;IProperties;IProperty;IProvider;ISetter</PackageTags>
<PackageTags>LinksPlatform;Interfaces;ICounter;IMatcher;IFactory;IProperties;IProperty;IProvider;ISetter</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>icon.png</PackageIcon>
<PackageProjectUrl>https://linksplatform.github.io/Interfaces</PackageProjectUrl>
Expand All @@ -23,7 +23,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<DebugType>embedded</DebugType>
<LangVersion>latest</LangVersion>
<PackageReleaseNotes>Fix package publishing while preserving embedded symbols, eliminate C# workflow warnings, validate NuGet artifacts before release, and add downloadable DocFX API documentation in PDF format.</PackageReleaseNotes>
<PackageReleaseNotes>Breaking change: rename ICriterionMatcher to IMatcher. Matcher input is named candidate; update implementations and references to the new interface.</PackageReleaseNotes>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
Loading