Skip to content

Commit e9cf52d

Browse files
Fix #1390: Extension methods used in collection initializers were not converted correctly.
1 parent 98261c7 commit e9cf52d

6 files changed

Lines changed: 466 additions & 323 deletions

File tree

ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
2727
{
2828
public static class Extensions
2929
{
30-
public static void Add(this TestCases.CustomList<int> inst, int a, int b)
30+
public static void Add(this TestCases.CustomList<int> inst, string a, string b)
31+
{
32+
}
33+
34+
public static void Add<T>(this IList<KeyValuePair<string, string>> collection, string key, T value, Func<T, string> convert = null)
3135
{
3236
}
3337
}
@@ -1544,13 +1548,13 @@ public static void ExtensionMethodInCollectionInitializer()
15441548
#if CS60
15451549
X(Y(), new CustomList<int> {
15461550
{
1547-
1,
1548-
2
1551+
"1",
1552+
"2"
15491553
}
15501554
});
15511555
#else
15521556
CustomList<int> customList = new CustomList<int>();
1553-
customList.Add(1, 2);
1557+
customList.Add("1", "2");
15541558
X(Y(), customList);
15551559
#endif
15561560
}
@@ -1703,7 +1707,33 @@ private void Issue1250_Test4(int value)
17031707
[(object)value] = new S(value)
17041708
});
17051709
}
1710+
1711+
public static void Issue1390(IEnumerable<string> tokens, bool alwaysAllowAdministrators, char wireDelimiter)
1712+
{
1713+
#if OPT
1714+
List<KeyValuePair<string, string>> obj = new List<KeyValuePair<string, string>> {
1715+
#else
1716+
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>> {
1717+
#endif
1718+
{
1719+
"tokens",
1720+
string.Join(wireDelimiter.ToString(), tokens),
1721+
(Func<string, string>)null
1722+
},
1723+
{
1724+
"alwaysAllowAdministrators",
1725+
alwaysAllowAdministrators.ToString(),
1726+
(Func<string, string>)null
1727+
},
1728+
{
1729+
"delimiter",
1730+
wireDelimiter.ToString(),
1731+
(Func<string, string>)null
1732+
}
1733+
};
1734+
}
1735+
17061736
#endif
17071737
#endregion
1708-
}
1738+
}
17091739
}

0 commit comments

Comments
 (0)