Skip to content

Commit 0c7a8a0

Browse files
committed
Added user defined parameter and return value conversion examples.
1 parent b9ad1bb commit 0c7a8a0

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

docs/guides-basic/dotnet-native-aot-support.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,52 @@ public static string? NativeGetAssemblyName(System.Reflection.Assembly assembly)
540540
| A1 | =NativeGetExecutingAssembly() | NativeGetExecutingAssembly:1
541541
| A2 | =NativeGetAssemblyName(A1) | ExcelDna.AddIn.RuntimeTestsAOT64
542542

543+
# User defined parameter and return value conversions
544+
545+
```csharp
546+
public class TestType1
547+
{
548+
public string Value;
549+
550+
public TestType1(string value)
551+
{
552+
Value = value;
553+
}
554+
}
555+
556+
public class Conversions
557+
{
558+
[ExcelParameterConversion]
559+
public static Version ToVersion(string s)
560+
{
561+
return new Version(s);
562+
}
563+
564+
[ExcelReturnConversion]
565+
public static string FromTestType1(TestType1 value)
566+
{
567+
return value.Value;
568+
}
569+
}
570+
571+
[ExcelFunction]
572+
public static string NativeVersion2(Version v)
573+
{
574+
return "The Native Version value with field count 2 is " + v.ToString(2);
575+
}
576+
577+
[ExcelFunction]
578+
public static TestType1 NativeReturnTestType1(string s)
579+
{
580+
return new TestType1("The Native TestType1 return value is " + s);
581+
}
582+
```
583+
584+
| Cell | Formula | Result
585+
| ----- | ----------------------------------| ------
586+
| A1 | =NativeVersion2("4.3.2.1") | The Native Version value with field count 2 is 4.3
587+
| A2 | =NativeReturnTestType1("world") | The Native TestType1 return value is world
588+
543589
# Not supported functionality in native add-ins
544590

545591
Loading images for ribbon controls.

0 commit comments

Comments
 (0)