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
2 changes: 2 additions & 0 deletions CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ limitations under the License.

[assembly: AssemblyVersion("2013.3.1021.0")]
[assembly: AssemblyFileVersion("2013.3.1021.0")]

[assembly: AssemblyMetadata("BuildDate", "2013/10/21")]
34 changes: 34 additions & 0 deletions Telerik.JustMock/Core/Licensing/LicenseException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
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
{
/// <summary>
/// The exception that is thrown in case of licensing error
/// </summary>
[Serializable]
public class LicenseException : MockException
{
public LicenseException() : base() { }

public LicenseException(string message) : base(message) { }

public LicenseException(string message, Exception innerException) : base(message, innerException) { }
}
}
91 changes: 91 additions & 0 deletions Telerik.JustMock/Core/Licensing/LicenseManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
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<AssemblyMetadataAttribute>();
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
}
8 changes: 7 additions & 1 deletion Telerik.JustMock/Core/MocksRepository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
JustMock Lite
Copyright © 2010-2015,2018-2019,2021-2022 Progress Software Corporation
Copyright © 2010-2015,2018-2019,2021-2022,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.
Expand Down Expand Up @@ -31,6 +31,7 @@ limitations under the License.
using Telerik.JustMock.Core.TransparentProxy;
using Telerik.JustMock.Diagnostics;
using Telerik.JustMock.Expectations;
using Telerik.JustMock.Core.Licensing;
#if DEBUG
using Telerik.JustMock.Helpers;
#endif
Expand Down Expand Up @@ -133,6 +134,11 @@ internal bool IsRetired

static MocksRepository()
{
if (!Licensing.LicenseManager.IsLicenseValid)
{
throw new Licensing.LicenseException(Licensing.LicenseManager.Message);
}

#if !COREFX
var badApples = new[]
{
Expand Down
19 changes: 8 additions & 11 deletions Telerik.JustMock/Core/ProfilerInterceptor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
JustMock Lite
Copyright © 2010-2015,2021-2023 Progress Software Corporation
Copyright © 2010-2015,2021-2023,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.
Expand Down Expand Up @@ -671,16 +671,13 @@ public static void Identify()

public static void ThrowElevatedMockingException(MemberInfo member = null)
{
var marker = typeof(object).Assembly.GetType("Telerik.JustMock.TrialExpiredMarker");
if (marker == null)
{
var ex = member != null ? new ElevatedMockingException(member) : new ElevatedMockingException();
throw ex;
}
else
{
throw new Trial.JustMockExpiredException();
}
var ex =
member != null
?
new ElevatedMockingException(member)
:
new ElevatedMockingException();
throw ex;
}

public static bool IsProfilerAttached { [DebuggerHidden] get { return bridge != null; } }
Expand Down
1 change: 1 addition & 0 deletions Telerik.JustMock/Telerik.JustMock.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ProjectGuid>{0749EBC2-4E83-4960-BF28-1FF5C2DEB2B9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(PreviewTargetFramework)' != '' ">
<TargetFrameworks>$(TargetFrameworks);$(PreviewTargetFramework)</TargetFrameworks>
Expand Down