diff --git a/Telerik.JustMock/Core/Licensing/LicenseException.cs b/Telerik.JustMock/Core/Licensing/LicenseException.cs deleted file mode 100644 index 360a1cf3..00000000 --- a/Telerik.JustMock/Core/Licensing/LicenseException.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* - JustMock Lite - Copyright © 2025 Progress Software Corporation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -using System; - -namespace Telerik.JustMock.Core.Licensing -{ - /// - /// The exception that is thrown in case of licensing error - /// - [Serializable] - public sealed class LicenseException : MockException - { - public LicenseException() : base() { } - - public LicenseException(string message) : base(message) { } - - public LicenseException(string message, Exception innerException) : base(message, innerException) { } - } -} diff --git a/Telerik.JustMock/Core/Licensing/LicenseManager.cs b/Telerik.JustMock/Core/Licensing/LicenseManager.cs deleted file mode 100644 index 0978ece3..00000000 --- a/Telerik.JustMock/Core/Licensing/LicenseManager.cs +++ /dev/null @@ -1,91 +0,0 @@ -/* - JustMock Lite - Copyright © 2025 Progress Software Corporation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -using System; -using System.Linq; -using System.Reflection; - -namespace Telerik.JustMock.Core.Licensing -{ -#nullable enable - public static class LicenseManager - { - private const string DefaultProductName = "Telerik JustMock Lite"; - private const string DefaultProductCode = "JM"; - private const string DefaultLicenseType = "free"; - private static readonly DateTime DefaultLicenseDate = DateTime.Now; - - private static string? licenseProductName; - private static DateTime licenseDate; - - public static bool IsLicenseValid => true; - - public static bool IsLicenseKeyFileFound => false; - - public static bool IsLicenseKeyFileValid => false; - - public static string? LicenseProductName - { - get - { - if (licenseProductName == null) - { - var assemblyProductAttribute = typeof(LicenseManager).Assembly.GetCustomAttribute(typeof(AssemblyProductAttribute)) as AssemblyProductAttribute; - licenseProductName = - assemblyProductAttribute == null - ? - DefaultProductName - : - assemblyProductAttribute.Product; - } - return licenseProductName; - } - } - - public static string LicenseProductCode => DefaultProductCode; - - public static string? LicenseProductVersion => typeof(LicenseManager).Assembly.GetName().Version.ToString(); - - public static DateTime? LicenseExpiration => null; - - public static DateTime LicenseDate - { - get - { - if (licenseDate == null) - { - licenseDate = DefaultLicenseDate; - var assemblyMetadataAttributes = typeof(LicenseManager).Assembly.GetCustomAttributes().OfType(); - foreach (var assemblyMetadataAttribute in assemblyMetadataAttributes) - { - if (assemblyMetadataAttribute.Key == "BuildDate") - { - licenseDate = DateTime.Parse(assemblyMetadataAttribute.Value); - break; - } - } - } - return licenseDate; - } - } - - public static string? LicenseType => DefaultLicenseType; - - public static string Message = String.Empty; - } -#nullable disable -} diff --git a/Telerik.JustMock/Core/MocksRepository.cs b/Telerik.JustMock/Core/MocksRepository.cs index 3da0cb4f..6c5073e7 100644 --- a/Telerik.JustMock/Core/MocksRepository.cs +++ b/Telerik.JustMock/Core/MocksRepository.cs @@ -31,7 +31,9 @@ limitations under the License. using Telerik.JustMock.Core.TransparentProxy; using Telerik.JustMock.Diagnostics; using Telerik.JustMock.Expectations; +#if FEATURE_LICENSING using Telerik.JustMock.Core.Licensing; +#endif #if DEBUG using Telerik.JustMock.Helpers; #endif @@ -134,10 +136,12 @@ internal bool IsRetired static MocksRepository() { +#if FEATURE_LICENSING if (!Licensing.LicenseManager.IsLicenseValid) { throw new Licensing.LicenseException(Licensing.LicenseManager.Message); } +#endif #if !COREFX var badApples = new[] diff --git a/Telerik.JustMock/Telerik.JustMock.csproj b/Telerik.JustMock/Telerik.JustMock.csproj index b3be19ab..cdef80f9 100644 --- a/Telerik.JustMock/Telerik.JustMock.csproj +++ b/Telerik.JustMock/Telerik.JustMock.csproj @@ -11,6 +11,7 @@ false Debug AnyCPU + false {0749EBC2-4E83-4960-BF28-1FF5C2DEB2B9} Library Properties @@ -57,6 +58,11 @@ prompt MinimumRecommendedRules.ruleset + + $(DefineConstants);FEATURE_LICENSING + ..\..\CodeBase\Build\Licensing + ..\..\call-home + $(DefineConstants);FEATURE_APPDOMAIN;FEATURE_ASSEMBLYBUILDER_SAVE @@ -221,4 +227,5 @@ + \ No newline at end of file