Fix some small issues and experiment with C#
This commit is contained in:
48
examples/cs/Example.sln
Normal file
48
examples/cs/Example.sln
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyClass", "My\MyClass.csproj", "{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OtherClass", "Other\OtherClass.csproj", "{EAA4714F-3F2E-4801-81B7-9BC502347B53}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Release|x64.Build.0 = Release|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F480EEA9-B211-4BDF-A364-8B8D1B6F4FCE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Release|x64.Build.0 = Release|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{EAA4714F-3F2E-4801-81B7-9BC502347B53}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
19
examples/cs/My/MyClass.cs
Normal file
19
examples/cs/My/MyClass.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using OtherNamespace;
|
||||
|
||||
namespace MyNamespace {
|
||||
public class MyClass {
|
||||
// This method will be called by native code inside the target process…
|
||||
public static int MyMethod(String pwzArgument) {
|
||||
System.Console.WriteLine("Hello World from C# {0}", pwzArgument);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void Main() {
|
||||
int my = MyMethod("from Main()");
|
||||
System.Console.WriteLine("MyMethod returned {0}", my);
|
||||
int other = OtherNamespace.OtherClass.OtherMethod();
|
||||
System.Console.WriteLine("OtherMethod returned {0}", other);
|
||||
}
|
||||
}
|
||||
}
|
10
examples/cs/My/MyClass.csproj
Normal file
10
examples/cs/My/MyClass.csproj
Normal file
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Other\OtherClass.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
11
examples/cs/Other/OtherClass.cs
Normal file
11
examples/cs/Other/OtherClass.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace OtherNamespace {
|
||||
public class OtherClass {
|
||||
// This method will be called by native code inside the target process…
|
||||
public static int OtherMethod() {
|
||||
System.Console.WriteLine("Goodbye World from C#");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
7
examples/cs/Other/OtherClass.csproj
Normal file
7
examples/cs/Other/OtherClass.csproj
Normal file
@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>OtherNamespace</RootNamespace>
|
||||
</PropertyGroup>
|
||||
</Project>
|
17
examples/cs/README.md
Normal file
17
examples/cs/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# C# Example
|
||||
|
||||
To compile:
|
||||
|
||||
```sh
|
||||
sudo pacman -S dotnet-host dotnet-runtime dotnet-sdk
|
||||
dotnet build
|
||||
```
|
||||
|
||||
To run:
|
||||
|
||||
```sh
|
||||
./My/bin/Debug/net8.0/MyClass
|
||||
# or
|
||||
sudo pacman -S mono
|
||||
mono My/bin/Debug/net8.0/MyClass.dll
|
||||
```
|
Reference in New Issue
Block a user