Skip to content

Commit 39eb1a3

Browse files
committed
C#: Remove assembly qualifier from some trap-ids.
1 parent 6685a5e commit 39eb1a3

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Method.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ public override void WriteId(TextWriter trapFile)
201201
/// </summary>
202202
protected static void AddSignatureTypeToId(Context cx, TextWriter trapFile, IMethodSymbol method, ITypeSymbol type)
203203
{
204-
if (type.ContainsTypeParameters(cx, method))
205-
type.BuildTypeId(cx, trapFile, (cx0, tb0, type0) => AddSignatureTypeToId(cx, tb0, method, type0));
206-
else
207-
trapFile.WriteSubId(Type.Create(cx, type));
204+
type.BuildTypeId(cx, trapFile, false, (cx0, tb0, type0) => AddSignatureTypeToId(cx, tb0, method, type0));
208205
}
209206

210207
protected static void AddParametersToId(Context cx, TextWriter trapFile, IMethodSymbol method)

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/NamedType.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public override IEnumerable<Extraction.Entities.Location> Locations
111111

112112
public override void WriteId(TextWriter trapFile)
113113
{
114-
symbol.BuildTypeId(Context, trapFile, (cx0, tb0, sub) => tb0.WriteSubId(Create(cx0, sub)));
114+
symbol.BuildTypeId(Context, trapFile, true, (cx0, tb0, sub) => tb0.WriteSubId(Create(cx0, sub)));
115115
trapFile.Write(";type");
116116
}
117117

@@ -177,7 +177,11 @@ class NamedTypeRefFactory : ICachedEntityFactory<INamedTypeSymbol, NamedTypeRef>
177177

178178
public override void WriteId(TextWriter trapFile)
179179
{
180-
trapFile.WriteSubId(referencedType);
180+
void WriteType(Context cx, TextWriter trapFile, ITypeSymbol symbol)
181+
{
182+
symbol.BuildTypeId(cx, trapFile, false, WriteType);
183+
}
184+
WriteType(Context, trapFile, referencedType.symbol);
181185
trapFile.Write(";typeRef");
182186
}
183187

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/TupleType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TupleTypeFactory : ICachedEntityFactory<INamedTypeSymbol, TupleType>
3232

3333
public override void WriteId(TextWriter trapFile)
3434
{
35-
symbol.BuildTypeId(Context, trapFile, (cx0, tb0, sub) => tb0.WriteSubId(Create(cx0, sub)));
35+
symbol.BuildTypeId(Context, trapFile, false, (cx0, tb0, sub) => tb0.WriteSubId(Create(cx0, sub)));
3636
trapFile.Write(";tuple");
3737
}
3838

csharp/extractor/Semmle.Extraction.CSharp/SymbolExtensions.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ public static bool ContainsTypeParameters(this ITypeSymbol type, Context cx, ISy
131131
/// <param name="cx">The extraction context.</param>
132132
/// <param name="trapFile">The trap builder used to store the result.</param>
133133
/// <param name="subTermAction">The action to apply to syntactic sub terms of this type.</param>
134-
public static void BuildTypeId(this ITypeSymbol type, Context cx, TextWriter trapFile, Action<Context, TextWriter, ITypeSymbol> subTermAction)
134+
public static void BuildTypeId(this ITypeSymbol type, Context cx, TextWriter trapFile, bool prefix, Action<Context, TextWriter, ITypeSymbol> subTermAction)
135135
{
136-
if (type.SpecialType != SpecialType.None)
136+
if (type.SpecialType != SpecialType.None && !(type is INamedTypeSymbol n && n.IsGenericType))
137137
{
138138
/*
139139
* Use the keyword ("int" etc) for the built-in types.
@@ -160,7 +160,7 @@ public static void BuildTypeId(this ITypeSymbol type, Context cx, TextWriter tra
160160
case TypeKind.Delegate:
161161
case TypeKind.Error:
162162
var named = (INamedTypeSymbol)type;
163-
named.BuildNamedTypeId(cx, trapFile, subTermAction);
163+
named.BuildNamedTypeId(cx, trapFile, prefix, subTermAction);
164164
return;
165165
case TypeKind.Pointer:
166166
var ptr = (IPointerTypeSymbol)type;
@@ -211,9 +211,8 @@ private static void BuildAssembly(IAssemblySymbol asm, TextWriter trapFile, bool
211211
trapFile.Write("::");
212212
}
213213

214-
static void BuildNamedTypeId(this INamedTypeSymbol named, Context cx, TextWriter trapFile, Action<Context, TextWriter, ITypeSymbol> subTermAction)
214+
static void BuildNamedTypeId(this INamedTypeSymbol named, Context cx, TextWriter trapFile, bool prefixAssembly, Action<Context, TextWriter, ITypeSymbol> subTermAction)
215215
{
216-
bool prefixAssembly = true;
217216
if (named.ContainingAssembly is null) prefixAssembly = false;
218217

219218
if (named.IsTupleType)

0 commit comments

Comments
 (0)