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 .net example to support .Net5 #4

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
15 changes: 12 additions & 3 deletions cs/net core/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ namespace ArmaDotNetCore
{
public class ArmaExtension
{
//You can call back to Arma by using Callback(string name, string function, string data);
public static unsafe delegate* unmanaged<string, string, string, int> Callback;

[UnmanagedCallersOnly(EntryPoint = "RVExtensionRegisterCallback")]
public static unsafe void RvExtensionRegisterCallback(delegate* unmanaged<string, string, string, int> callback)
{
Callback = callback;
}

//This tells the compiler to create an entrypoint named 'RVExtension'. This line should be added
// to each method you want to export. Only public static are accepted.
[UnmanagedCallersOnly(EntryPoint = "RVExtension")]
Expand All @@ -19,7 +28,7 @@ public class ArmaExtension
/// <param name="output">A pointer to the memory location of a chars array that will be read after issuing callExtension command</param>
/// <param name="outputSize">An integer that determines the maximum lenght of the array</param>
/// <param name="function">A pointer to the string passed from arma</param>
public unsafe static void RVExtension(char* output, int outputSize, char* function)
public static unsafe void RVExtension(char* output, int outputSize, char* function)
{
//Let's grab the string from the pointer passed from the Arma call to our extension
//Note the explicit cast
Expand Down Expand Up @@ -55,7 +64,7 @@ we have to convert it to a byte array in order to allow the arma extension loade
/// <param name="argv">An array of pointers (char**). IE: A pointer to a memory location where pointers are stored(Still, can't be casted to IntPtr)</param>
/// <param name="argc">Integer that points how many arguments there are in argv</param>

public unsafe static void RVExtensionArgs(char* output, int outputSize, char* function, char** argv, int argc)
public static unsafe void RVExtensionArgs(char* output, int outputSize, char* function, char** argv, int argc)
{
//Let's grab the string from the pointer passed from the Arma call to our extension
//Note the explicit cast
Expand Down Expand Up @@ -94,7 +103,7 @@ we have to convert it to a byte array in order to allow the arma extension loade
/// <param name="output">A pointer to the memory location of a chars array that will be read after the load of the extension.</param>
/// <param name="outputSize">An integer that determines the maximum lenght of the array</param>

public unsafe static void RVExtensionVersion(char* output, int outputSize)
public static unsafe void RVExtensionVersion(char* output, int outputSize)
{
string greetingsString = "|Arma .NET Core Sample|";

Expand Down
5 changes: 3 additions & 2 deletions cs/net core/dotnet_a3.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetName>dotnet_a3_x64</TargetName>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="6.0.0-*" />
</ItemGroup>
</Project>
14 changes: 7 additions & 7 deletions cs/net core/nuget.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>