Navigation Menu

Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Fix for a bug reported by a user. In general, the entire reading and …
Browse files Browse the repository at this point in the history
…writing of serialized type names should be replaced by the code that is in CCI2.
  • Loading branch information
mike-barnett committed Jul 21, 2017
1 parent 86174fe commit 7063bdd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
27 changes: 27 additions & 0 deletions ILMerge.Tests/Inputs/SerializedTypeName.cs
@@ -0,0 +1,27 @@
namespace SerializedTypeName
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

public class M : ITwoTypeArgs<int, int>
{
internal static void Main()
{
var asm = Assembly.GetCallingAssembly();
var types = asm.DefinedTypes;
Console.WriteLine(types.First());
}

IEnumerator<int> ITwoTypeArgs<int, int>.Mk()
{
yield return 42;
}
}

public interface ITwoTypeArgs<T1, T2>
{
IEnumerator<int> Mk();
}
}
6 changes: 6 additions & 0 deletions System.Compiler/Reader.cs
Expand Up @@ -42,6 +42,7 @@
using Marshal = System.Runtime.InteropServices.Marshal;
using System.Runtime.InteropServices;
using System.IO;
using System.Text;

#if CCINamespace
namespace Microsoft.Cci.Metadata{
Expand Down Expand Up @@ -1715,20 +1716,25 @@ private AssemblyNode.PostAssemblyLoadProcessor ReferringAssemblyPostLoad
private static void ParseSimpleTypeName(string/*!*/ source, out string/*!*/ name, ref int i) {
int n = source.Length;
int start = i;
var sb = new StringBuilder();
for (; i < n; i++){
char ch = source[i];
if (ch == '\\'){ i++; continue;}
if (ch == '.' || ch == '+' || ch == '&' || ch == '*' || ch == '[' || ch == '!') break;
sb.Append(ch);
if (ch == '<'){
int unmatched = 1;
while (unmatched > 0 && ++i < n){
ch = source[i];
if (ch != '\\') sb.Append(ch); else sb.Append(source[i + 1]);
if (ch == '\\') i++;
else if (ch == '<') unmatched++;
else if (ch == '>') unmatched--;
}
}
}
name = sb.ToString();
return;
if (i < n)
name = source.Substring(start, i-start);
else
Expand Down
12 changes: 7 additions & 5 deletions System.Compiler/Writer.cs
Expand Up @@ -4668,16 +4668,18 @@ void WriteMethodSpecSignature(BinaryWriter/*!*/ target, Method/*!*/ method)
sb.Append('&');
goto done;
}
if (type.Template == null)
sb.Append(type.FullName);
else{
if (type.Template == null){
var escapedName = type.FullName.Replace(",", "\\,");
sb.Append(escapedName);
}else{
sb.Append(type.Template.FullName);
sb.Append('[');
for (int i = 0, n = type.ConsolidatedTemplateArguments == null ? 0 : type.ConsolidatedTemplateArguments.Count; i < n; i++) {
for (int i = 0, n = type.ConsolidatedTemplateArguments == null ? 0 : type.ConsolidatedTemplateArguments.Count; i < n; i++)
{
//^ assert type.ConsolidatedTemplateArguments != null;
bool isAssemQual = true;
this.AppendSerializedTypeName(sb, type.ConsolidatedTemplateArguments[i], ref isAssemQual);
if (i < n-1) sb.Append(',');
if (i < n - 1) sb.Append(',');
}
sb.Append(']');
}
Expand Down

0 comments on commit 7063bdd

Please sign in to comment.