Skip to content

Commit 4c54a32

Browse files
committed
Work on Interop sample
- Rename folders and solution for clarity. - Update NuGet packages. Signed-off-by: José Simões <[email protected]>
1 parent c9c0682 commit 4c54a32

19 files changed

+19
-39
lines changed

samples/Interop/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ This project illustrates the use of the 'Interop' feature which allow a C# manag
44

55
There are two Solutions in this sample:
66

7-
- In the [*source*](/source) folder you'll find the solution for the Interop managed library: `NF.AwesomeLib.sln`.
8-
- In the [*test-application*](/test-application) folder you'll find the test application that is referencing the Interop library: `Test.Interop.sln`.
7+
- In the [*awesome-library*](awesome-library/) folder you'll find the solution with the Interop library: `NF.AwesomeLib.sln`.
8+
- In the [*test-application*](test-application/) folder you'll find the test application that is referencing the Interop library: `Test.Interop.sln`.
99

10-
:warning: This is an advanced topic. Please read this [blog post](https://jsimoesblog.wordpress.com/2018/06/19/interop-in-net-nanoframework/) with a detailed explanation on how to create, build and use an Interop library.
10+
:warning: This is an advanced topic. :warning:
11+
12+
Please read this [blog post](https://jsimoesblog.wordpress.com/2018/06/19/interop-in-net-nanoframework/) with a detailed explanation on how to create, build and use an Interop library.
1113

1214
> **Note:** This sample is part of a large collection of nanoFramework feature samples.
1315
> If you are unfamiliar with Git and GitHub, you can download the entire collection as a
File renamed without changes.

samples/Interop/source/NF.AwesomeLib.nfproj samples/Interop/awesome-library/NF.AwesomeLib.nfproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<Compile Include="Utilities.cs" />
2828
</ItemGroup>
2929
<ItemGroup>
30-
<Reference Include="mscorlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
31-
<HintPath>packages\nanoFramework.CoreLibrary.1.0.0-preview054\lib\mscorlib.dll</HintPath>
30+
<Reference Include="mscorlib, Version=1.2.6.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
31+
<HintPath>packages\nanoFramework.CoreLibrary.1.2.6-preview.19\lib\mscorlib.dll</HintPath>
3232
<Private>True</Private>
3333
<SpecificVersion>True</SpecificVersion>
3434
</Reference>

samples/Interop/source/Stubs/NF_AwesomeLib.cpp samples/Interop/awesome-library/Stubs/NF_AwesomeLib.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_NF_AwesomeLib =
2525
"NF.AwesomeLib",
2626
0xBB94F141,
2727
method_lookup,
28+
////////////////////////////////////////////////////////////////////////////////////
29+
// check if the version bellow matches the one in AssemblyNativeVersion attribute //
30+
////////////////////////////////////////////////////////////////////////////////////
2831
{ 1, 0, 0, 0 }
2932
};

samples/Interop/source/Stubs/NF_AwesomeLib.h samples/Interop/awesome-library/Stubs/NF_AwesomeLib.h

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _NF_AWESOMELIB_H_
1212

1313
#include <nanoCLR_Interop.h>
14+
#include <nanoCLR_Runtime.h>
1415
struct Library_NF_AwesomeLib_NF_AwesomeLib_Math
1516
{
1617
NANOCLR_NATIVE_DECLARE(NativeSuperComplicatedCalculation___STATIC__R8__R8);

samples/Interop/source/Stubs/NF_AwesomeLib_NF_AwesomeLib_Math.cpp samples/Interop/awesome-library/Stubs/NF_AwesomeLib_NF_AwesomeLib_Math.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@
99
// re-run.
1010
//
1111
//-----------------------------------------------------------------------------
12-
13-
1412
#include "NF_AwesomeLib.h"
1513
#include "NF_AwesomeLib_NF_AwesomeLib_Math.h"
1614

1715
using namespace NF::AwesomeLib;
1816

1917
double Math::NativeSuperComplicatedCalculation( double param0, HRESULT &hr )
2018
{
21-
(void)hr;
22-
2319
double retVal = 0;
24-
retVal = param0 + 1;
2520
return retVal;
2621
}
2722

samples/Interop/source/Stubs/NF_AwesomeLib_NF_AwesomeLib_Math.h samples/Interop/awesome-library/Stubs/NF_AwesomeLib_NF_AwesomeLib_Math.h

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// re-run.
1010
//
1111
//-----------------------------------------------------------------------------
12-
13-
1412
#ifndef _NF_AWESOMELIB_NF_AWESOMELIB_MATH_H_
1513
#define _NF_AWESOMELIB_NF_AWESOMELIB_MATH_H_
1614

samples/Interop/source/Stubs/NF_AwesomeLib_NF_AwesomeLib_Utilities.cpp samples/Interop/awesome-library/Stubs/NF_AwesomeLib_NF_AwesomeLib_Utilities.cpp

-17
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,12 @@
99
// re-run.
1010
//
1111
//-----------------------------------------------------------------------------
12-
13-
1412
#include "NF_AwesomeLib.h"
1513
#include "NF_AwesomeLib_NF_AwesomeLib_Utilities.h"
1614

1715
using namespace NF::AwesomeLib;
1816

1917
void Utilities::NativeGetHardwareSerial( CLR_RT_TypedArray_UINT8 param0, HRESULT &hr )
2018
{
21-
if (param0.GetSize() < 12)
22-
{
23-
hr=CLR_E_BUFFER_TOO_SMALL;
24-
return;
25-
}
26-
27-
// Device line - Starting address
28-
// F0, F3 - 0x1FFFF7AC
29-
// F1 - 0x1FFFF7E8
30-
// F2, F4 - 0x1FFF7A10
31-
// F7 - 0x1FF0F420
32-
// L0 - 0x1FF80050
33-
// L0, L1 Cat.1,Cat.2 - 0x1FF80050
34-
// L1 Cat.3,Cat.4,Cat.5,Cat.6 - 0x1FF800D0
35-
memcpy((void*)param0.GetBuffer(), (const void*)0x1FF0F420, 12);
3619
}
3720

samples/Interop/source/Stubs/NF_AwesomeLib_NF_AwesomeLib_Utilities.h samples/Interop/awesome-library/Stubs/NF_AwesomeLib_NF_AwesomeLib_Utilities.h

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// re-run.
1010
//
1111
//-----------------------------------------------------------------------------
12-
13-
1412
#ifndef _NF_AWESOMELIB_NF_AWESOMELIB_UTILITIES_H_
1513
#define _NF_AWESOMELIB_NF_AWESOMELIB_UTILITIES_H_
1614

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="nanoFramework.CoreLibrary" version="1.2.6-preview.19" targetFramework="netnanoframework10" />
4+
</packages>

samples/Interop/source/packages.config

-4
This file was deleted.

samples/Interop/test-application/Test.Interop.nfproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
<Compile Include="Properties\AssemblyInfo.cs" />
2323
</ItemGroup>
2424
<ItemGroup>
25-
<Reference Include="mscorlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
26-
<HintPath>packages\nanoFramework.CoreLibrary.1.0.0-preview054\lib\mscorlib.dll</HintPath>
25+
<Reference Include="mscorlib, Version=1.2.6.0, Culture=neutral, PublicKeyToken=c07d481e9758c731">
26+
<HintPath>packages\nanoFramework.CoreLibrary.1.2.6-preview.19\lib\mscorlib.dll</HintPath>
2727
<Private>True</Private>
2828
<SpecificVersion>True</SpecificVersion>
2929
</Reference>
3030
<Reference Include="NF.AwesomeLib">
31-
<HintPath>..\source\bin\Debug\NF.AwesomeLib.dll</HintPath>
31+
<HintPath>..\awesome-library\bin\Debug\NF.AwesomeLib.dll</HintPath>
3232
</Reference>
3333
</ItemGroup>
3434
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="nanoFramework.CoreLibrary" version="1.0.0-preview054" targetFramework="netnanoframework10" />
3+
<package id="nanoFramework.CoreLibrary" version="1.2.6-preview.19" targetFramework="netnanoframework10" />
44
</packages>

0 commit comments

Comments
 (0)