Skip to content

Commit 6cfd87c

Browse files
authored
Merge pull request #1031 from PlayEveryWare/feat/managed-to-unmanaged-bridge
feat: `ManagedToUnmanagedBridge`
2 parents b0f8a54 + e51ff43 commit 6cfd87c

File tree

8 files changed

+326
-0
lines changed

8 files changed

+326
-0
lines changed

lib/NativeCode/DynamicLibraryLoaderHelper/DynamicLibraryLoaderHelper.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication", "Conso
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagedPluginCode", "ManagedPluginCode\ManagedPluginCode.csproj", "{B3ADEB07-B668-482E-A5AA-9671CE65C5F7}"
1313
EndProject
14+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ManagedToUnmanagedBridge", "ManagedToUnmanagedBridge\ManagedToUnmanagedBridge.vcxproj", "{4421F72C-9585-4245-BD8D-FEF6CE45C7D6}"
15+
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1618
Debug|x64 = Debug|x64
@@ -47,6 +49,12 @@ Global
4749
{B3ADEB07-B668-482E-A5AA-9671CE65C5F7}.Debug|x86.Build.0 = Debug|x86
4850
{B3ADEB07-B668-482E-A5AA-9671CE65C5F7}.Release|x64.ActiveCfg = Release|x64
4951
{B3ADEB07-B668-482E-A5AA-9671CE65C5F7}.Release|x86.ActiveCfg = Release|x86
52+
{4421F72C-9585-4245-BD8D-FEF6CE45C7D6}.Debug|x64.ActiveCfg = Debug|x64
53+
{4421F72C-9585-4245-BD8D-FEF6CE45C7D6}.Debug|x64.Build.0 = Debug|x64
54+
{4421F72C-9585-4245-BD8D-FEF6CE45C7D6}.Debug|x86.ActiveCfg = Debug|Win32
55+
{4421F72C-9585-4245-BD8D-FEF6CE45C7D6}.Debug|x86.Build.0 = Debug|Win32
56+
{4421F72C-9585-4245-BD8D-FEF6CE45C7D6}.Release|x64.ActiveCfg = Release|x64
57+
{4421F72C-9585-4245-BD8D-FEF6CE45C7D6}.Release|x86.ActiveCfg = Release|Win32
5058
EndGlobalSection
5159
GlobalSection(SolutionProperties) = preSolution
5260
HideSolutionNode = FALSE
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Release/*
2+
Debug/*
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "pch.h"
2+
3+
using namespace System;
4+
using namespace System::Reflection;
5+
using namespace System::Runtime::CompilerServices;
6+
using namespace System::Runtime::InteropServices;
7+
using namespace System::Security::Permissions;
8+
9+
[assembly:AssemblyTitleAttribute(L"ManagedToUnmanagedBridge")];
10+
[assembly:AssemblyDescriptionAttribute(L"Used as a proxy or bridge between managed and unmanaged code.")];
11+
[assembly:AssemblyConfigurationAttribute(L"")];
12+
[assembly:AssemblyCompanyAttribute(L"PlayEveryWare, Inc.")];
13+
[assembly:AssemblyProductAttribute(L"EOS Plugin for Unity")];
14+
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2024")];
15+
[assembly:AssemblyTrademarkAttribute(L"")];
16+
[assembly:AssemblyCultureAttribute(L"en-US")];
17+
18+
[assembly:AssemblyVersionAttribute(L"1.0.*")];
19+
20+
[assembly:ComVisible(false)];
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#ifndef CONFIGURATION_UTILITY_BRIDGE_HPP
2+
#define CONFIGURATION_UTILITY_BRIDGE_HPP
3+
4+
/*
5+
* Copyright (c) 2024 PlayEveryWare
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
26+
#pragma once
27+
28+
using namespace System;
29+
30+
/**
31+
* Reference the dll generated by the managed plugin code project - which
32+
* points to the C# files within the Unity project that are used to read and
33+
* determine configuration values.
34+
*/
35+
#using <ManagedPluginCode.dll>
36+
37+
namespace pew::eos::tests {
38+
using namespace Epic::OnlineServices::Platform;
39+
using namespace PlayEveryWare::EpicOnlineServices::Utility;
40+
41+
/**
42+
* \brief This ref class is used to call a function defined in managed code
43+
* from an unmanaged (native) context.
44+
*/
45+
public ref class ConfigurationUtilityBridge
46+
{
47+
public:
48+
/**
49+
* \brief Get the windows options - as determined by the product and
50+
* windows config values set out in the JSON configuration files.
51+
* \return A proxy object that points to the WindowsOptions whose values
52+
* have been determined by the managed (C#) plugin code.
53+
*/
54+
static WindowsOptions^ get_windows_options()
55+
{
56+
return ConfigurationUtility::GetEOSCreateOptions()->options;
57+
}
58+
59+
/**
60+
* \brief Get the InitializeOptions - as determined by the product and
61+
* windows config values set out in the JSON configuration files.
62+
* \return A proxy object that points to the InitializeOptions whose
63+
* values have been determined by the managed (C#) plugin code.
64+
*/
65+
static InitializeOptions^ get_initialize_options()
66+
{
67+
return ConfigurationUtility::GetEOSInitializeOptions()->options;
68+
}
69+
};
70+
}
71+
72+
#endif
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>17.0</VCProjectVersion>
23+
<ProjectGuid>{4421F72C-9585-4245-BD8D-FEF6CE45C7D6}</ProjectGuid>
24+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
25+
<Keyword>ManagedCProj</Keyword>
26+
<RootNamespace>ManagedToUnmanagedBridge</RootNamespace>
27+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
28+
</PropertyGroup>
29+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
30+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
31+
<ConfigurationType>DynamicLibrary</ConfigurationType>
32+
<UseDebugLibraries>true</UseDebugLibraries>
33+
<PlatformToolset>v143</PlatformToolset>
34+
<CLRSupport>true</CLRSupport>
35+
<CharacterSet>Unicode</CharacterSet>
36+
</PropertyGroup>
37+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
38+
<ConfigurationType>DynamicLibrary</ConfigurationType>
39+
<UseDebugLibraries>false</UseDebugLibraries>
40+
<PlatformToolset>v143</PlatformToolset>
41+
<CLRSupport>true</CLRSupport>
42+
<CharacterSet>Unicode</CharacterSet>
43+
</PropertyGroup>
44+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
45+
<ConfigurationType>DynamicLibrary</ConfigurationType>
46+
<UseDebugLibraries>true</UseDebugLibraries>
47+
<PlatformToolset>v143</PlatformToolset>
48+
<CLRSupport>true</CLRSupport>
49+
<CharacterSet>Unicode</CharacterSet>
50+
</PropertyGroup>
51+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
52+
<ConfigurationType>DynamicLibrary</ConfigurationType>
53+
<UseDebugLibraries>false</UseDebugLibraries>
54+
<PlatformToolset>v143</PlatformToolset>
55+
<CLRSupport>true</CLRSupport>
56+
<CharacterSet>Unicode</CharacterSet>
57+
</PropertyGroup>
58+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
59+
<ImportGroup Label="ExtensionSettings">
60+
</ImportGroup>
61+
<ImportGroup Label="Shared">
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
73+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
74+
</ImportGroup>
75+
<PropertyGroup Label="UserMacros" />
76+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
77+
<OutDir>$(SolutionDir)Build\$(Configuration)\x86\</OutDir>
78+
<IntDir>$(SolutionDir)Build\Temp\$(Configuration)\x86\</IntDir>
79+
<ManagedAssembly>true</ManagedAssembly>
80+
</PropertyGroup>
81+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
82+
<OutDir>$(SolutionDir)Build\$(Configuration)\x86\</OutDir>
83+
<IntDir>$(SolutionDir)Build\Temp\$(Configuration)\x86\</IntDir>
84+
<ManagedAssembly>true</ManagedAssembly>
85+
</PropertyGroup>
86+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
87+
<OutDir>$(SolutionDir)Build\$(Configuration)\$(Platform)\</OutDir>
88+
<IntDir>$(SolutionDir)Build\Temp\$(Configuration)\$(Platform)\</IntDir>
89+
<ManagedAssembly>true</ManagedAssembly>
90+
</PropertyGroup>
91+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
92+
<OutDir>$(SolutionDir)Build\$(Configuration)\$(Platform)\</OutDir>
93+
<IntDir>$(SolutionDir)Build\Temp\$(Configuration)\$(Platform)\</IntDir>
94+
<ManagedAssembly>true</ManagedAssembly>
95+
</PropertyGroup>
96+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
97+
<ClCompile>
98+
<PrecompiledHeader>Use</PrecompiledHeader>
99+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
100+
<WarningLevel>Level3</WarningLevel>
101+
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
102+
<AdditionalUsingDirectories>$(SolutionDir)Build\$(Configuration)\$(Platform)\</AdditionalUsingDirectories>
103+
<LanguageStandard>stdcpp17</LanguageStandard>
104+
<AdditionalIncludeDirectories>$(SolutionDir)Build\$(Configuration)\$(Platform)\</AdditionalIncludeDirectories>
105+
</ClCompile>
106+
<Link>
107+
<AdditionalDependencies />
108+
</Link>
109+
</ItemDefinitionGroup>
110+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
111+
<ClCompile>
112+
<PrecompiledHeader>Use</PrecompiledHeader>
113+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
114+
<WarningLevel>Level3</WarningLevel>
115+
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
116+
<AdditionalUsingDirectories>$(SolutionDir)Build\$(Configuration)\$(Platform)\</AdditionalUsingDirectories>
117+
<LanguageStandard>stdcpp17</LanguageStandard>
118+
<AdditionalIncludeDirectories>$(SolutionDir)Build\$(Configuration)\$(Platform)\</AdditionalIncludeDirectories>
119+
</ClCompile>
120+
<Link>
121+
<AdditionalDependencies />
122+
</Link>
123+
</ItemDefinitionGroup>
124+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
125+
<ClCompile>
126+
<PrecompiledHeader>Use</PrecompiledHeader>
127+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
128+
<WarningLevel>Level3</WarningLevel>
129+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
130+
<AdditionalUsingDirectories>$(SolutionDir)Build\$(Configuration)\$(Platform)\</AdditionalUsingDirectories>
131+
<LanguageStandard>stdcpp17</LanguageStandard>
132+
<AdditionalIncludeDirectories>$(SolutionDir)Build\$(Configuration)\$(Platform)\</AdditionalIncludeDirectories>
133+
</ClCompile>
134+
<Link>
135+
<AdditionalDependencies />
136+
</Link>
137+
</ItemDefinitionGroup>
138+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
139+
<ClCompile>
140+
<PrecompiledHeader>Use</PrecompiledHeader>
141+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
142+
<WarningLevel>Level3</WarningLevel>
143+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
144+
<AdditionalUsingDirectories>$(SolutionDir)Build\$(Configuration)\$(Platform)\</AdditionalUsingDirectories>
145+
<LanguageStandard>stdcpp17</LanguageStandard>
146+
<AdditionalIncludeDirectories>$(SolutionDir)Build\$(Configuration)\$(Platform)\</AdditionalIncludeDirectories>
147+
</ClCompile>
148+
<Link>
149+
<AdditionalDependencies />
150+
</Link>
151+
</ItemDefinitionGroup>
152+
<ItemGroup>
153+
<ClInclude Include="ConfigurationUtilityBridge.hpp" />
154+
<ClInclude Include="pch.h" />
155+
</ItemGroup>
156+
<ItemGroup>
157+
<ClCompile Include="AssemblyInfo.cpp" />
158+
<ClCompile Include="pch.cpp">
159+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
160+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
161+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
162+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
163+
</ClCompile>
164+
</ItemGroup>
165+
<ItemGroup>
166+
<Reference Include="System" />
167+
<Reference Include="System.Data" />
168+
<Reference Include="System.Xml" />
169+
</ItemGroup>
170+
<ItemGroup>
171+
<ProjectReference Include="..\ManagedPluginCode\ManagedPluginCode.csproj">
172+
<Project>{b3adeb07-b668-482e-a5aa-9671ce65c5f7}</Project>
173+
</ProjectReference>
174+
</ItemGroup>
175+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
176+
<ImportGroup Label="ExtensionTargets">
177+
</ImportGroup>
178+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
</ItemGroup>
13+
<ItemGroup>
14+
<ClInclude Include="ConfigurationUtilityBridge.hpp">
15+
<Filter>Header Files</Filter>
16+
</ClInclude>
17+
<ClInclude Include="pch.h">
18+
<Filter>Header Files</Filter>
19+
</ClInclude>
20+
</ItemGroup>
21+
<ItemGroup>
22+
<ClCompile Include="AssemblyInfo.cpp">
23+
<Filter>Source Files</Filter>
24+
</ClCompile>
25+
<ClCompile Include="pch.cpp">
26+
<Filter>Source Files</Filter>
27+
</ClCompile>
28+
</ItemGroup>
29+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// pch.cpp: source file corresponding to the pre-compiled header
2+
3+
#include "pch.h"
4+
5+
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// pch.h: This is a precompiled header file.
2+
// Files listed below are compiled only once, improving build performance for future builds.
3+
// This also affects IntelliSense performance, including code completion and many code browsing features.
4+
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
5+
// Do not add files here that you will be updating frequently as this negates the performance advantage.
6+
7+
#ifndef PCH_H
8+
#define PCH_H
9+
10+
// add headers that you want to pre-compile here
11+
12+
#endif //PCH_H

0 commit comments

Comments
 (0)