-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[generator] Strip arity from Cecil imported types. (#450)
Context: #424 One of the issues trying to bind the BouncyCastle-provided [`bcprov-ext-jdk15on-161.jar.`][0] in #424 is that we write generic types with invalid signatures: public List`1<string> MyProperty { get; set; } as this is how a Cecil type reference `FullName` is returned. Since this notation is not useful to us, strip the "arity" information when reading the assembly. This results in the proper type syntax: public List<string> MyProperty { get; set; } [0]: https://www.bouncycastle.org/download/bcprov-ext-jdk15on-161.jar
- Loading branch information
Showing
5 changed files
with
100 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tools/generator/Tests/Unit-Tests/ManagedExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using MonoDroid.Generation; | ||
using NUnit.Framework; | ||
|
||
namespace generatortests | ||
{ | ||
[TestFixture] | ||
public class ManagedExtensionsTests | ||
{ | ||
[Test] | ||
public void StripArity () | ||
{ | ||
Assert.AreEqual ("List<string>", "List`1<string>".StripArity ()); | ||
Assert.AreEqual ("List<List<string>>", "List`10<List`1<string>>".StripArity ()); | ||
Assert.AreEqual ("List<string>", "List<string>".StripArity ()); | ||
Assert.AreEqual ("List`1", "List`1".StripArity ()); | ||
Assert.AreEqual ("L<blah>ist<string>", "L<blah>ist`1<string>".StripArity ()); | ||
Assert.AreEqual ("List<string>", "List`1`<string>".StripArity ()); | ||
Assert.AreEqual ("List<<string>", "List`1<<string>".StripArity ()); | ||
Assert.AreEqual ("List<", "List`<".StripArity ()); | ||
Assert.AreEqual ("<", "`1<".StripArity ()); | ||
Assert.AreEqual ("`", "`".StripArity ()); | ||
Assert.AreEqual (string.Empty, string.Empty.StripArity ()); | ||
Assert.IsNull ((null as string).StripArity ()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters