diff --git a/documentation/23.09/solutions/dotnet/eiffel-net-language/eiffel-net-integration/Workaround-Eiffel-.NET-limitations.wiki b/documentation/23.09/solutions/dotnet/eiffel-net-language/eiffel-net-integration/Workaround-Eiffel-.NET-limitations.wiki index 1c692afa..8657664f 100644 --- a/documentation/23.09/solutions/dotnet/eiffel-net-language/eiffel-net-integration/Workaround-Eiffel-.NET-limitations.wiki +++ b/documentation/23.09/solutions/dotnet/eiffel-net-language/eiffel-net-integration/Workaround-Eiffel-.NET-limitations.wiki @@ -1,6 +1,66 @@ -[[Property:modification_date|Mon, 02 Oct 2023 10:23:24 GMT]] +[[Property:modification_date|Mon, 02 Oct 2023 10:25:19 GMT]] [[Property:publication_date|Mon, 02 Oct 2023 10:22:20 GMT]] [[Property:uuid|AF5801CA-928B-4870-BCC4-53DCAB23AF96]] [[Property:weight|10]] [[Property:title|Workaround Eiffel .NET limitations]] [[Property:link_title|Workarounds]] + +==Using generic .NET classes through a facade== +Currently, Eiffel does not support consuming generics from C# classes. This tutorial demonstrates a workaround for this limitation by creating a Facade for a `List` in C# + +===Creating a facade for the List type=== +A Facade simplifies access to complex components. In this case, we will create a Facade to manage a list of strings. The Facade will encapsulate the list's functionality and expose a more straightforward interface. Here's how you can do it: + + +using System.Collections; +namespace ListOfString; + +/// +/// Facade for a List that encapsulates the list's functionality and exposes a few methods +/// +public class ListOfString +{ + private List _list; + + public ListOfString() + { + _list = new List(); + } + + public void Add(string item) + { + _list.Add(item); + } + + public bool Contains(string item) + { + return _list.Contains(item); + } + + public void Remove(string item) + { + _list.Remove(item); + } + + public IList GetList() + { + return _list.ToList(); + } +} + + +===Creating a C# library=== +To consume the Facade in Eiffel, we need to create a C# library. I recommend following the tutorial on creating a class library with C# and .NET on Microsoft’s official site. You can access it [https://learn.microsoft.com/en-us/dotnet/core/tutorials/library-with-visual-studio?pivots=dotnet-7-0 here]. This tutorial guides you through the process of creating a class library using C# and .NET. + +===Consuming the C# library from Eiffel=== +Finally, we need to consume the C# library from Eiffel. + +Open the Eiffel configuration file (.ecf) of your project and add the following entry + + + + +===Conclusion=== +By creating a Facade for a `List` in C#, we can effectively consume C# generic features in Eiffel. +This approach can be extended to other generic types as well. +