diff --git a/.github/scripts/validate-csharp-package.sh b/.github/scripts/validate-csharp-package.sh index d255b703..4255424d 100755 --- a/.github/scripts/validate-csharp-package.sh +++ b/.github/scripts/validate-csharp-package.sh @@ -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 diff --git a/cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp b/cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp index 745edc68..b23633cf 100644 --- a/cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp +++ b/cpp/Platform.Interfaces.Tests/Platform.Interfaces.Tests.cpp @@ -81,17 +81,22 @@ namespace Platform::Interfaces::Tests { } } - TEST(CompileTests, CriterionMatcher) { - struct EmptyCriterionMatcher : public ICriterionMatcher { - bool IsMatched(int) { return {}; } + TEST(CompileTests, Matcher) { + struct MinimumMatcher : public IMatcher { + int minimum; + explicit MinimumMatcher(int value) : minimum(value) {} + bool IsMatched(int candidate) override { return candidate >= minimum; } }; - static_assert(CCriterionMatcher); + static_assert(CMatcher); { - CCriterionMatcher auto criterionMatcher = EmptyCriterionMatcher{}; + CMatcher auto matcher = MinimumMatcher{10}; + IMatcher& interface = matcher; - ASSERT_TRUE((CCriterionMatcher)); - ASSERT_TRUE((CCriterionMatcher)); + ASSERT_TRUE((CMatcher)); + ASSERT_TRUE((CMatcher)); + ASSERT_FALSE(interface.IsMatched(9)); + ASSERT_TRUE(interface.IsMatched(10)); } } diff --git a/cpp/Platform.Interfaces/CCriterionMatcher.h b/cpp/Platform.Interfaces/CCriterionMatcher.h deleted file mode 100644 index 348f42d9..00000000 --- a/cpp/Platform.Interfaces/CCriterionMatcher.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include - -namespace Platform::Interfaces { - template - concept CCriterionMatcher = requires(TSelf self, TArgument argument) { - { self.IsMatched(argument) } -> std::same_as; - }; -} // namespace Platform::Interfaces diff --git a/cpp/Platform.Interfaces/CMatcher.h b/cpp/Platform.Interfaces/CMatcher.h new file mode 100644 index 00000000..66f8b229 --- /dev/null +++ b/cpp/Platform.Interfaces/CMatcher.h @@ -0,0 +1,10 @@ +#pragma once + +#include + +namespace Platform::Interfaces { + template + concept CMatcher = requires(TSelf self, TCandidate candidate) { + { self.IsMatched(candidate) } -> std::same_as; + }; +} // namespace Platform::Interfaces diff --git a/cpp/Platform.Interfaces/ICriterionMatcher.h b/cpp/Platform.Interfaces/ICriterionMatcher.h deleted file mode 100644 index a2fc4784..00000000 --- a/cpp/Platform.Interfaces/ICriterionMatcher.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -namespace Platform::Interfaces { - template - struct ICriterionMatcher; - - template - struct ICriterionMatcher { - virtual bool IsMatched(TArgument argument) = 0; - - virtual ~ICriterionMatcher() = default; - }; -} // namespace Platform::Interfaces diff --git a/cpp/Platform.Interfaces/IMatcher.h b/cpp/Platform.Interfaces/IMatcher.h new file mode 100644 index 00000000..017f96b8 --- /dev/null +++ b/cpp/Platform.Interfaces/IMatcher.h @@ -0,0 +1,13 @@ +#pragma once + +namespace Platform::Interfaces { + template + struct IMatcher; + + template + struct IMatcher { + virtual bool IsMatched(TCandidate candidate) = 0; + + virtual ~IMatcher() = default; + }; +} // namespace Platform::Interfaces diff --git a/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.nuspec b/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.nuspec index ac877563..c7be134c 100644 --- a/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.nuspec +++ b/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.nuspec @@ -5,8 +5,8 @@ LinksPlatform's Platform.Interfaces Template Library LinksPlatform's Platform.Interfaces is a Template Library what contains common concepts templates. LinksPlatform's Platform.Interfaces is a Template Library what contains set of C++ concepts templates. Use Platform.Interfaces.h file to include the library. - Test release for automatic deploy system. - 0.3.43 + Breaking change: rename ICriterionMatcher to IMatcher and CCriterionMatcher to CMatcher. Update header includes and references. + 0.4.0 konard, uselessgoddess, Mitron57 konard, uselessgoddess, Mitron57 konard, uselessgoddess, Mitron57 diff --git a/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.vcxproj b/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.vcxproj index e52d17dc..eb8f68d3 100644 --- a/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.vcxproj +++ b/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.vcxproj @@ -144,7 +144,7 @@ - + @@ -157,4 +157,4 @@ - \ No newline at end of file + diff --git a/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.vcxproj.filters b/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.vcxproj.filters index 2565dc4e..0c802976 100644 --- a/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.vcxproj.filters +++ b/cpp/Platform.Interfaces/Platform.Interfaces.TemplateLibrary.vcxproj.filters @@ -21,7 +21,7 @@ Header Files - + Header Files @@ -49,4 +49,4 @@ Header Files - \ No newline at end of file + diff --git a/cpp/Platform.Interfaces/Platform.Interfaces.h b/cpp/Platform.Interfaces/Platform.Interfaces.h index ff317a7e..df1b8f66 100644 --- a/cpp/Platform.Interfaces/Platform.Interfaces.h +++ b/cpp/Platform.Interfaces/Platform.Interfaces.h @@ -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" @@ -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" diff --git a/csharp/Platform.Interfaces.Tests/InterfacesTests.cs b/csharp/Platform.Interfaces.Tests/InterfacesTests.cs index 212f4af2..f1297550 100644 --- a/csharp/Platform.Interfaces.Tests/InterfacesTests.cs +++ b/csharp/Platform.Interfaces.Tests/InterfacesTests.cs @@ -11,7 +11,7 @@ public static void BuildTest() { ICounter? c1 = null; ICounter? c2 = null; - ICriterionMatcher? cm1 = null; + IMatcher? cm1 = null; IFactory? f1 = null; IProperties? p1 = null; IProperty? p2 = null; @@ -32,6 +32,15 @@ public static void BuildTest() Assert.Null(s2); } + [Fact] + public static void MatcherTestsCandidate() + { + IMatcher matcher = new MinimumMatcher(10); + + Assert.False(matcher.IsMatched(9)); + Assert.True(matcher.IsMatched(10)); + } + [Fact] public static void AssemblyContainsEmbeddedPortablePdb() { @@ -42,5 +51,10 @@ public static void AssemblyContainsEmbeddedPortablePdb() peReader.ReadDebugDirectory(), entry => entry.Type == DebugDirectoryEntryType.EmbeddedPortablePdb); } + + private sealed class MinimumMatcher(int minimum) : IMatcher + { + public bool IsMatched(int candidate) => candidate >= minimum; + } } } diff --git a/csharp/Platform.Interfaces/ICriterionMatcher.cs b/csharp/Platform.Interfaces/ICriterionMatcher.cs deleted file mode 100644 index 68928362..00000000 --- a/csharp/Platform.Interfaces/ICriterionMatcher.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace Platform.Interfaces -{ - /// - /// Defines a criterion matcher, that contains a specific method for determining whether the argument matches the criterion or not. - /// Определяет объект который проверяет соответствие критерию и содержит конкретный метод для определения, соответствует ли аргумент критерию или нет. - /// - /// - /// Argument type. - /// Тип аргумента. - /// - public interface ICriterionMatcher - { - /// - /// Determines whether the argument matches the criterion. - /// Определяет, соответствует ли аргумент критерию. - /// - /// - /// The argument. - /// Аргумент. - /// - /// - /// A value that determines whether the argument matches the criterion. - /// Значение, определяющие соответствует ли аргумент критерию. - /// - bool IsMatched(TArgument argument); - } -} diff --git a/csharp/Platform.Interfaces/IMatcher.cs b/csharp/Platform.Interfaces/IMatcher.cs new file mode 100644 index 00000000..aab486da --- /dev/null +++ b/csharp/Platform.Interfaces/IMatcher.cs @@ -0,0 +1,27 @@ +namespace Platform.Interfaces +{ + /// + /// Defines a matcher that determines whether a candidate satisfies its matching rule. + /// Определяет объект, который проверяет, соответствует ли кандидат правилу сопоставления. + /// + /// + /// Type of the value being tested for a match. + /// Тип значения, проверяемого на соответствие. + /// + public interface IMatcher + { + /// + /// Determines whether the candidate satisfies the matching rule. + /// Определяет, соответствует ли кандидат правилу сопоставления. + /// + /// + /// The value to test. + /// Проверяемое значение. + /// + /// + /// Whether the candidate satisfies the matching rule. + /// Соответствует ли кандидат правилу сопоставления. + /// + bool IsMatched(TCandidate candidate); + } +} diff --git a/csharp/Platform.Interfaces/Platform.Interfaces.csproj b/csharp/Platform.Interfaces/Platform.Interfaces.csproj index 733ee7d9..f05f43fc 100644 --- a/csharp/Platform.Interfaces/Platform.Interfaces.csproj +++ b/csharp/Platform.Interfaces/Platform.Interfaces.csproj @@ -4,12 +4,12 @@ LinksPlatform's Platform.Interfaces Class Library Konstantin Diachenko Platform.Interfaces - 0.5.3 + 0.6.0 Konstantin Diachenko net8 Platform.Interfaces Platform.Interfaces - LinksPlatform;Interfaces;ICounter;ICriterionMatcher;IFactory;IProperties;IProperty;IProvider;ISetter + LinksPlatform;Interfaces;ICounter;IMatcher;IFactory;IProperties;IProperty;IProvider;ISetter README.md icon.png https://linksplatform.github.io/Interfaces @@ -23,7 +23,7 @@ true embedded latest - 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. + Breaking change: rename ICriterionMatcher to IMatcher. Matcher input is named candidate; update implementations and references to the new interface. enable