Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 2024 Q2 and Q3 releases #214

Merged
merged 5 commits into from
Aug 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Telerik.JustMock, Version=2013.3.1021.0, Culture=neutral, PublicKeyToken=721b6c5bc0326b3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\Binaries\$(Configuration)\net45\Telerik.JustMock.dll</HintPath>
<Reference Include="Telerik.JustMock">
<HintPath>..\..\..\..\..\Binaries\$(Configuration)\net472\Telerik.JustMock.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Telerik.JustMock, Version=2013.3.1021.0, Culture=neutral, PublicKeyToken=721b6c5bc0326b3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\Binaries\$(Configuration)\net45\Telerik.JustMock.dll</HintPath>
<Reference Include="Telerik.JustMock">
<HintPath>..\..\..\..\..\Binaries\$(Configuration)\net472\Telerik.JustMock.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Telerik.JustMock">
<HintPath>..\..\..\..\..\Binaries\$(Configuration)\net45\Telerik.JustMock.dll</HintPath>
<HintPath>..\..\..\..\..\Binaries\$(Configuration)\net472\Telerik.JustMock.dll</HintPath>
</Reference>
</ItemGroup>
<Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Telerik.JustMock">
<HintPath>..\..\..\..\..\Binaries\$(Configuration)\net45\Telerik.JustMock.dll</HintPath>
<HintPath>..\..\..\..\..\Binaries\$(Configuration)\net472\Telerik.JustMock.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions Telerik.JustMock.DemoLib/Telerik.JustMock.DemoLib.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net45;net472;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<NetCoreSupportedVersions>netcoreapp3.1;net5.0</NetCoreSupportedVersions>
<TargetFrameworks>net472;$(NetCoreSupportedVersions)</TargetFrameworks>
<Configurations>Debug;Release;ReleaseFree;DebugFree</Configurations>
<AssemblyName>Telerik.JustMock.DemoLib</AssemblyName>
<RootNamespace>Telerik.JustMock.DemoLib</RootNamespace>
Expand Down Expand Up @@ -47,7 +48,7 @@
<CodeAnalysisRuleDirectories>;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugFree|AnyCPU'">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugFree|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\DebugFree\</OutputPath>
<DefineConstants>TRACE;DEBUG;LITE_EDITION</DefineConstants>
Expand All @@ -56,7 +57,7 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' Or '$(TargetFramework)' == 'netcoreapp3.1'">
<PropertyGroup Condition=" $(NetCoreSupportedVersions.Contains('$(TargetFramework)')) ">
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
</PropertyGroup>
<PropertyGroup>
Expand Down Expand Up @@ -96,7 +97,7 @@
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile />
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net472' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<Reference Include="System.Web" />
<Reference Include="System.Data.DataSetExtensions" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net45;net472;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<NetCoreSupportedVersions>netcoreapp3.1;net5.0</NetCoreSupportedVersions>
<TargetFrameworks>net472;$(NetCoreSupportedVersions)</TargetFrameworks>
<Configurations>Debug;Release;DebugFree;ReleaseFree</Configurations>
<AssemblyName>Telerik.JustMock.DemoLibSigned</AssemblyName>
<RootNamespace>Telerik.JustMock.DemoLibSigned</RootNamespace>
Expand All @@ -22,7 +23,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFree|AnyCPU'">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)'=='DebugFree|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
Expand All @@ -39,15 +40,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseFree|AnyCPU'">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)'=='ReleaseFree|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\ReleaseFree\</OutputPath>
<DefineConstants>TRACE;LITE_EDITION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' Or '$(TargetFramework)' == 'netcoreapp3.1'">
<PropertyGroup Condition=" $(NetCoreSupportedVersions.Contains('$(TargetFramework)')) ">
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
</PropertyGroup>
<PropertyGroup>
Expand All @@ -73,7 +74,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>snkey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net472' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
<Reference Include="System.Data.DataSetExtensions" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\JustMockLite\Build\Config.targets"></Import>

<PropertyGroup>
<TargetFramework>net451</TargetFramework>
<TargetFramework>net472</TargetFramework>
<Configurations>Debug;Release;ReleaseFree;DebugFree</Configurations>
<AssemblyName>Telerik.JustMock.MSTest.Tests</AssemblyName>
<RootNamespace>Telerik.JustMock.Tests</RootNamespace>
Expand Down Expand Up @@ -73,7 +73,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Dynamic.Runtime " Version="4.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<NetCoreSupportedVersions>netcoreapp3.1;net5.0</NetCoreSupportedVersions>
<TargetFrameworks>net461;net472;$(NetCoreSupportedVersions)</TargetFrameworks>
<TargetFrameworks>net472;$(NetCoreSupportedVersions)</TargetFrameworks>
<Configurations>Debug;Release;ReleaseFree;DebugFree</Configurations>
<AssemblyName>Telerik.JustMock.MSTest2.Tests</AssemblyName>
<RootNamespace>Telerik.JustMock.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net451;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<Configurations>Debug;Release;DebugFree;ReleaseFree</Configurations>
<AssemblyName>Telerik.JustMock.NUnit.Tests</AssemblyName>
<RootNamespace>Telerik.JustMock.Tests</RootNamespace>
Expand All @@ -16,7 +16,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFree|AnyCPU'">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)'=='DebugFree|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
Expand All @@ -35,7 +35,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseFree|AnyCPU'">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)'=='ReleaseFree|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\ReleaseFree\</OutputPath>
Expand All @@ -44,7 +44,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' Or '$(TargetFramework)' == 'netcoreapp3.1'">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
</PropertyGroup>
<PropertyGroup>
Expand Down
10 changes: 5 additions & 5 deletions Telerik.JustMock.XUnit.Tests/Telerik.JustMock.XUnit.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;net472;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
<Configurations>Debug;Release;DebugFree;ReleaseFree</Configurations>
<AssemblyName>Telerik.JustMock.XUnit.Tests</AssemblyName>
<RootNamespace>Telerik.JustMock.Tests</RootNamespace>
Expand All @@ -16,7 +16,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFree|AnyCPU'">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)'=='DebugFree|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
Expand All @@ -35,7 +35,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseFree|AnyCPU'">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)'=='ReleaseFree|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
Expand All @@ -44,7 +44,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' Or '$(TargetFramework)' == 'netcoreapp3.1'">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
</PropertyGroup>
<PropertyGroup>
Expand Down Expand Up @@ -73,6 +73,6 @@
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="System.Dynamic.Runtime " Version="4.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
</Project>
39 changes: 33 additions & 6 deletions Telerik.JustMock/Core/Behaviors/RaiseEventBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
JustMock Lite
Copyright © 2010-2015 Progress Software Corporation
Copyright © 2010-2015,2024 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 All @@ -16,6 +16,7 @@ limitations under the License.
*/

using System;
using System.Linq;
using System.Reflection;

namespace Telerik.JustMock.Core.Behaviors
Expand Down Expand Up @@ -60,18 +61,42 @@ public void Process(object[] invocationArgs, Type declaringType)
public static void RaiseEventImpl(object instance, EventInfo evt, object[] args)
{
if (evt == null)
{
throw new MockException("Unable to deduce which event was specified in the parameter.");
}

if (args == null)
{
args = new object[] { null };
}

if (args.Length == 1
&& (evt.EventHandlerType.IsGenericType && evt.EventHandlerType.GetGenericTypeDefinition() == typeof(EventHandler<>)
|| evt.EventHandlerType == typeof(EventHandler)
|| args[0] is EventArgs)
)
bool shouldInsertEventSender = false;

// check whether the event handler is EventHandler or EventHandler<> compliant and insert
// the sender argument automatically if it is not explicitly supplied
if (evt.EventHandlerType.IsGenericType
&& evt.EventHandlerType.GetGenericTypeDefinition() == typeof(EventHandler<>))
{
shouldInsertEventSender = args.Length == 1
&& evt.EventHandlerType.GetGenericArguments().Length == 1
&& evt.EventHandlerType.GetGenericArguments()[0].IsAssignableFrom(args[0]?.GetType());
}
else if (evt.EventHandlerType == typeof(EventHandler))
{
shouldInsertEventSender = args.Length == 1
&& (args[0] == null || typeof(EventArgs).IsAssignableFrom(args[0]?.GetType()));
}
else
{
// special case with (Object, T) handler signature, where T is any type
var eventHandlerParams = evt.EventHandlerType.GetMethod("Invoke").GetParameters();
shouldInsertEventSender = args.Length == 1
&& eventHandlerParams.Length == 2
&& eventHandlerParams[0].ParameterType == typeof(object)
&& eventHandlerParams[1].ParameterType.IsAssignableFrom(args[0]?.GetType());
}

if (shouldInsertEventSender)
{
args = new[] { instance, args[0] };
}
Expand All @@ -80,7 +105,9 @@ public static void RaiseEventImpl(object instance, EventInfo evt, object[] args)
{
var mockMixin = MocksRepository.GetMockMixin(instance, evt.DeclaringType);
if (mockMixin != null)
{
instance = mockMixin;
}
}

var mixin = instance as IEventsMixin;
Expand Down
2 changes: 1 addition & 1 deletion Telerik.JustMock/Core/Context/MockingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static IDisposable BeginFailureAggregation(string message)
private static PluginLoadHelper pluginLoadHelper;
#if NETCORE
private const string NET_CORE_DESC_PATTERN = @".NET(\sCore)?\s(\d+(\.)?)+";
private const string NET_CORE_SUBDIR = "netcoreapp2.1";
private const string NET_CORE_SUBDIR = "netcoreapp3.1";
#endif
#endif

Expand Down
7 changes: 4 additions & 3 deletions Telerik.JustMock/Core/MockingUtil.CodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,16 @@ public static Delegate CreateDynamicMethod(Type delegateType, Action<ILGenerator
// "The return Type contains some invalid type(i.e. null, ByRef)". In order to make
// it working we are applying the following simple workaround:
// 1. Pass a non-ref type to constructor and create dynamic method instance
// 2. Using reflection change the value of private field 'm_returnType' of the
// newly created dynamic method to be ByRef type
// 2. Using reflection change the value of the private field representing the
// return type of the newly created dynamic method to be ByRef type
Type dynamicReturnType = (returnType.IsByRef) ? returnType.GetElementType() : returnType;

var method = new DynamicMethod("DynamicMethod_" + Guid.NewGuid().ToString("N"), dynamicReturnType, parameterTypes, true);

if (returnType.IsByRef)
{
method.GetType().GetField("m_returnType", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)
var returnTypeFieldName = Environment.Version.Major >= 8 ? "_returnType" : "m_returnType";
method.GetType().GetField(returnTypeFieldName, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)
.SetValue(method, returnType);
}

Expand Down
Loading