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

Update namespaces, upgrade abstractions version, add tests for new Fi… #47

Merged
merged 10 commits into from
Oct 14, 2023
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
## [2.3.3]

### Added

- Introduced new user-defined exceptions to check whether an early-bound type is defined in multiple assemblies.
- New method to retrieve early bound types based on EntityTypeCode.

### Changed

- Upgraded GitHub Actions to update Java major version to run SonarCloud analysis - https://github.com/DynamicsValue/fake-xrm-easy/issues/110
º
- Update namespaces in tests project for consistency
- Upgraded GitHub Actions to update Java major version to run SonarCloud analysis - https://github.com/DynamicsValue/fake-xrm-easy/issues/110
- Introduced new NewEntityRecord method to easily create instances of entity records based on the current use of early-bound or late-bound entities
- Resolves an issue with query evaluation and MultiOptionSets when using late bound entities or if type information is not present. - https://github.com/DynamicsValue/fake-xrm-easy/issues/66

Expand Down
83 changes: 46 additions & 37 deletions FakeXrmEasy.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
build.ps1 = build.ps1
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataverseEntities", "tests\DataverseEntities\DataverseEntities.csproj", "{7638E014-9149-4125-860F-D478CFD36C06}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
FAKE_XRM_EASY_9|Any CPU = FAKE_XRM_EASY_9|Any CPU
FAKE_XRM_EASY_9|x64 = FAKE_XRM_EASY_9|x64
FAKE_XRM_EASY_9|x86 = FAKE_XRM_EASY_9|x86
FAKE_XRM_EASY_2013|Any CPU = FAKE_XRM_EASY_2013|Any CPU
FAKE_XRM_EASY_2013|x64 = FAKE_XRM_EASY_2013|x64
FAKE_XRM_EASY_2013|x86 = FAKE_XRM_EASY_2013|x86
Expand All @@ -34,23 +36,11 @@ Global
FAKE_XRM_EASY_365|Any CPU = FAKE_XRM_EASY_365|Any CPU
FAKE_XRM_EASY_365|x64 = FAKE_XRM_EASY_365|x64
FAKE_XRM_EASY_365|x86 = FAKE_XRM_EASY_365|x86
FAKE_XRM_EASY_9|Any CPU = FAKE_XRM_EASY_9|Any CPU
FAKE_XRM_EASY_9|x64 = FAKE_XRM_EASY_9|x64
FAKE_XRM_EASY_9|x86 = FAKE_XRM_EASY_9|x86
FAKE_XRM_EASY|Any CPU = FAKE_XRM_EASY|Any CPU
FAKE_XRM_EASY|x64 = FAKE_XRM_EASY|x64
FAKE_XRM_EASY|x86 = FAKE_XRM_EASY|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Debug|x64.ActiveCfg = Debug|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Debug|x64.Build.0 = Debug|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Debug|x86.ActiveCfg = Debug|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Debug|x86.Build.0 = Debug|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_2013|Any CPU.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_2013|Any CPU.Build.0 = FAKE_XRM_EASY_2013|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_2013|x64.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
Expand Down Expand Up @@ -87,18 +77,6 @@ Global
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY|x64.Build.0 = FAKE_XRM_EASY|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY|x86.ActiveCfg = FAKE_XRM_EASY|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY|x86.Build.0 = FAKE_XRM_EASY|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Release|Any CPU.Build.0 = Debug|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Release|x64.ActiveCfg = FAKE_XRM_EASY|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Release|x64.Build.0 = FAKE_XRM_EASY|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Release|x86.ActiveCfg = FAKE_XRM_EASY|Any CPU
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.Release|x86.Build.0 = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Debug|x64.ActiveCfg = Debug|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Debug|x64.Build.0 = Debug|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Debug|x86.ActiveCfg = Debug|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Debug|x86.Build.0 = Debug|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY_2013|Any CPU.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY_2013|Any CPU.Build.0 = FAKE_XRM_EASY_2013|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY_2013|x64.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
Expand Down Expand Up @@ -131,23 +109,54 @@ Global
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY_9|x86.Build.0 = FAKE_XRM_EASY_9|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|Any CPU.ActiveCfg = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|Any CPU.Build.0 = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|x64.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|x64.Build.0 = FAKE_XRM_EASY_2013|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|x86.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|x86.Build.0 = FAKE_XRM_EASY_2013|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Release|Any CPU.Build.0 = Debug|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Release|x64.ActiveCfg = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Release|x64.Build.0 = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Release|x86.ActiveCfg = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.Release|x86.Build.0 = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|x64.ActiveCfg = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|x64.Build.0 = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|x86.ActiveCfg = FAKE_XRM_EASY|Any CPU
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8}.FAKE_XRM_EASY|x86.Build.0 = FAKE_XRM_EASY|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_9|Any CPU.ActiveCfg = FAKE_XRM_EASY_9|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_9|Any CPU.Build.0 = FAKE_XRM_EASY_9|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY|Any CPU.ActiveCfg = FAKE_XRM_EASY|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY|Any CPU.Build.0 = FAKE_XRM_EASY|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY|x64.ActiveCfg = FAKE_XRM_EASY|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY|x64.Build.0 = FAKE_XRM_EASY|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY|x86.ActiveCfg = FAKE_XRM_EASY|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY|x86.Build.0 = FAKE_XRM_EASY|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2013|Any CPU.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2013|Any CPU.Build.0 = FAKE_XRM_EASY_2013|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2013|x64.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2013|x64.Build.0 = FAKE_XRM_EASY_2013|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2013|x86.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2013|x86.Build.0 = FAKE_XRM_EASY_2013|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2015|Any CPU.ActiveCfg = FAKE_XRM_EASY_2015|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2015|Any CPU.Build.0 = FAKE_XRM_EASY_2015|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2015|x64.ActiveCfg = FAKE_XRM_EASY_2015|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2015|x64.Build.0 = FAKE_XRM_EASY_2015|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2015|x86.ActiveCfg = FAKE_XRM_EASY_2015|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2015|x86.Build.0 = FAKE_XRM_EASY_2015|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2016|Any CPU.ActiveCfg = FAKE_XRM_EASY_2016|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2016|Any CPU.Build.0 = FAKE_XRM_EASY_2016|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2016|x64.ActiveCfg = FAKE_XRM_EASY_2016|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2016|x64.Build.0 = FAKE_XRM_EASY_2016|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2016|x86.ActiveCfg = FAKE_XRM_EASY_2016|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_2016|x86.Build.0 = FAKE_XRM_EASY_2016|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_365|Any CPU.ActiveCfg = FAKE_XRM_EASY_365|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_365|Any CPU.Build.0 = FAKE_XRM_EASY_365|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_365|x64.ActiveCfg = FAKE_XRM_EASY_365|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_365|x64.Build.0 = FAKE_XRM_EASY_365|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_365|x86.ActiveCfg = FAKE_XRM_EASY_365|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_365|x86.Build.0 = FAKE_XRM_EASY_365|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_9|x64.ActiveCfg = FAKE_XRM_EASY_9|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_9|x64.Build.0 = FAKE_XRM_EASY_9|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_9|x86.ActiveCfg = FAKE_XRM_EASY_9|Any CPU
{7638E014-9149-4125-860F-D478CFD36C06}.FAKE_XRM_EASY_9|x86.Build.0 = FAKE_XRM_EASY_9|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE} = {6D8BD300-7945-4BD8-AFA5-30EEF1466332}
{E7FD9BE3-5CD1-4B50-A23E-53EA1AE2EBB8} = {AB19E6BB-17E9-4489-B6C8-A14622C147D9}
{7638E014-9149-4125-860F-D478CFD36C06} = {AB19E6BB-17E9-4489-B6C8-A14622C147D9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9E98B2F2-E752-4716-ABC6-BE9440866543}
Expand Down
39 changes: 39 additions & 0 deletions src/FakeXrmEasy.Core/Exceptions/FindReflectedTypeException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Reflection;
using System.Text;

namespace FakeXrmEasy.Core.Exceptions
{
/// <summary>
/// Exception raised when the generated early bound types have an unsupported format
/// </summary>
public class FindReflectedTypeException : Exception
{
/// <summary>
/// Default constructor
/// </summary>
/// <param name="message"></param>
public FindReflectedTypeException(string message) : base(message)
{

}

/// <summary>
/// Creates a FindReflectedException from a ReflectionTypeLoadException
/// </summary>
/// <param name="reflectionTypeLoadException"></param>
/// <returns></returns>
public static FindReflectedTypeException New(ReflectionTypeLoadException reflectionTypeLoadException)
{
// now look at ex.LoaderExceptions - this is an Exception[], so:
var s = new StringBuilder();
foreach (var innerException in reflectionTypeLoadException.LoaderExceptions)
{
// write details of "inner", in particular inner.Message
s.AppendLine(innerException.Message);
}

return new FindReflectedTypeException("XrmFakedContext.FindReflectedType: " + s.ToString());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace FakeXrmEasy.Core.Exceptions
{
/// <summary>
/// Exception raised when an early-bound type exists for the same logical name
/// or entity type code in more than one assembly and so it's impossible to decide which one should
/// be used
/// </summary>
public class MultipleEarlyBoundTypesFoundException : Exception
{
private readonly string _errorMessage;

/// <summary>
/// Creates a MultipleEarlyBoundTypesFoundException from a logical name
/// </summary>
/// <param name="logicalName">The searched logical name</param>
/// <param name="types">The types in which the logical name found</param>
public MultipleEarlyBoundTypesFoundException(string logicalName, IEnumerable<Type> types)
{
var baseMessage =
$"The early-bound type for logical name '{logicalName}' was found in more than one assembly. When using early-bound types, a given type must be unique across all the assemblies.";

var log = GenerateLog(types);

_errorMessage = $"{baseMessage} Assemblies where the type was found={log.ToString()}";
}

/// <summary>
/// Creates a MultipleEarlyBoundTypesFoundException from an EntityTypeCode
/// </summary>
/// <param name="entityTypeCode">The searched entity type code</param>
/// <param name="types">The types in which the entity type code was found</param>
public MultipleEarlyBoundTypesFoundException(int entityTypeCode, IEnumerable<Type> types)
{
var baseMessage =
$"The early-bound type for Entity Type Code '{entityTypeCode.ToString()}' was found in more than one assembly. When using early-bound types, a given type must be unique across all the assemblies.";

var log = GenerateLog(types);

_errorMessage = $"{baseMessage} Assemblies where the type was found={log.ToString()}";
}

private string GenerateLog(IEnumerable<Type> types)
{
var log = new StringBuilder();
foreach (var type in types)
{
log.AppendLine($"'{type.Assembly.GetName().Name}'; ");
}

return log.ToString();
}

/// <summary>
/// Returns the message along with the assemblies that caused this exception
/// </summary>
public override string Message => _errorMessage;
}
}
12 changes: 6 additions & 6 deletions src/FakeXrmEasy.Core/FakeXrmEasy.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='FAKE_XRM_EASY'">
<PackageReference Include="FakeXrmEasy.Abstractions.v2011" Version="[2.3.2-*,3.0)" />
<PackageReference Include="FakeXrmEasy.Abstractions.v2011" Version="[2.3.3-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='FAKE_XRM_EASY_2013'">
<PackageReference Include="FakeXrmEasy.Abstractions.v2013" Version="[2.3.2-*,3.0)" />
<PackageReference Include="FakeXrmEasy.Abstractions.v2013" Version="[2.3.3-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='FAKE_XRM_EASY_2015'">
<PackageReference Include="FakeXrmEasy.Abstractions.v2015" Version="[2.3.2-*,3.0)" />
<PackageReference Include="FakeXrmEasy.Abstractions.v2015" Version="[2.3.3-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='FAKE_XRM_EASY_2016'">
<PackageReference Include="FakeXrmEasy.Abstractions.v2016" Version="[2.3.2-*,3.0)" />
<PackageReference Include="FakeXrmEasy.Abstractions.v2016" Version="[2.3.3-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='FAKE_XRM_EASY_365'">
<PackageReference Include="FakeXrmEasy.Abstractions.v365" Version="[2.3.2-*,3.0)" />
<PackageReference Include="FakeXrmEasy.Abstractions.v365" Version="[2.3.3-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='FAKE_XRM_EASY_9'">
<PackageReference Include="FakeXrmEasy.Abstractions.v9" Version="[2.3.2-*,3.0)" />
<PackageReference Include="FakeXrmEasy.Abstractions.v9" Version="[2.3.3-*,3.0)" />
</ItemGroup>

<Target Name="PreparePackageReleaseNotesFromFile" BeforeTargets="GenerateNuspec">
Expand Down
Loading
Loading