Skip to content

Commit 25265bd

Browse files
authored
Merge pull request #2494 from calumgrant/cs/roslyn-3.4
C#: Upgrade Roslyn to 3.4
2 parents ed97be4 + 4b0a149 commit 25265bd

File tree

26 files changed

+351
-92
lines changed

26 files changed

+351
-92
lines changed

csharp/extractor/Semmle.Extraction.CIL/Entities/Attribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ sealed class Attribute : UnlabelledEntity, IAttribute
2323
public Attribute(Context cx, IEntity @object, CustomAttributeHandle handle) : base(cx)
2424
{
2525
attrib = cx.mdReader.GetCustomAttribute(handle);
26+
this.handle = handle;
2627
this.@object = @object;
2728
}
2829

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ IPropertySymbol PropertySymbol
2424
// But for properties/indexers that implement explicit interfaces, Roslyn
2525
// does not properly populate `AssociatedSymbol`
2626
var props = symbol.ContainingType.GetMembers().OfType<IPropertySymbol>();
27-
props = props.Where(p => symbol.Equals(p.GetMethod) || symbol.Equals(p.SetMethod));
27+
props = props.Where(p => SymbolEqualityComparer.Default.Equals(symbol, p.GetMethod) || SymbolEqualityComparer.Default.Equals(symbol, p.SetMethod));
2828
return props.SingleOrDefault();
2929
}
3030
}
@@ -47,12 +47,12 @@ public override void Populate(TextWriter trapFile)
4747
var parent = Property.Create(Context, prop);
4848
int kind;
4949
Accessor unboundAccessor;
50-
if (symbol.Equals(prop.GetMethod))
50+
if (SymbolEqualityComparer.Default.Equals(symbol, prop.GetMethod))
5151
{
5252
kind = 1;
5353
unboundAccessor = Create(Context, prop.OriginalDefinition.GetMethod);
5454
}
55-
else if (symbol.Equals(prop.SetMethod))
55+
else if (SymbolEqualityComparer.Default.Equals(symbol, prop.SetMethod))
5656
{
5757
kind = 2;
5858
unboundAccessor = Create(Context, prop.OriginalDefinition.SetMethod);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public override void Populate(TextWriter trapFile)
2020

2121
static new Destructor OriginalDefinition(Context cx, Destructor original, IMethodSymbol symbol)
2222
{
23-
return symbol.OriginalDefinition == null || Equals(symbol.OriginalDefinition, symbol) ? original : Create(cx, symbol.OriginalDefinition);
23+
return symbol.OriginalDefinition == null || SymbolEqualityComparer.Default.Equals(symbol.OriginalDefinition, symbol) ? original : Create(cx, symbol.OriginalDefinition);
2424
}
2525

2626
public new static Destructor Create(Context cx, IMethodSymbol symbol) =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public override void Populate(TextWriter trapFile)
2828
var parent = Event.Create(Context, @event);
2929
int kind;
3030
EventAccessor unboundAccessor;
31-
if (symbol.Equals(@event.AddMethod))
31+
if (SymbolEqualityComparer.Default.Equals(symbol, @event.AddMethod))
3232
{
3333
kind = 1;
3434
unboundAccessor = Create(Context, @event.OriginalDefinition.AddMethod);
3535
}
36-
else if (symbol.Equals(@event.RemoveMethod))
36+
else if (SymbolEqualityComparer.Default.Equals(symbol, @event.RemoveMethod))
3737
{
3838
kind = 2;
3939
unboundAccessor = Create(Context, @event.OriginalDefinition.RemoveMethod);

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Initializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected override void PopulateExpression(TextWriter trapFile)
106106
{
107107
var collectionInfo = cx.GetModel(Syntax).GetCollectionInitializerSymbolInfo(i);
108108
var addMethod = Method.Create(cx, collectionInfo.Symbol as IMethodSymbol);
109-
var voidType = Entities.Type.Create(cx, new AnnotatedTypeSymbol(cx.Compilation.GetSpecialType(SpecialType.System_Void), NullableAnnotation.NotApplicable));
109+
var voidType = Entities.Type.Create(cx, new AnnotatedTypeSymbol(cx.Compilation.GetSpecialType(SpecialType.System_Void), NullableAnnotation.None));
110110

111111
var invocation = new Expression(new ExpressionInfo(cx, voidType, cx.Create(i.GetLocation()), ExprKind.METHOD_INVOCATION, this, child++, false, null));
112112

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected void PopulateParameters(TextWriter trapFile)
4040

4141
foreach (var p in parameters.Zip(originalParameters, (paramSymbol, originalParam) => new { paramSymbol, originalParam }))
4242
{
43-
var original = Equals(p.paramSymbol, p.originalParam) ? null : Parameter.Create(Context, p.originalParam, originalMethod);
43+
var original = SymbolEqualityComparer.Default.Equals(p.paramSymbol, p.originalParam) ? null : Parameter.Create(Context, p.originalParam, originalMethod);
4444
Parameter.Create(Context, p.paramSymbol, this, original);
4545
}
4646

@@ -117,7 +117,7 @@ protected static void BuildMethodId(Method m, TextWriter trapFile)
117117

118118
if (m.symbol.IsGenericMethod)
119119
{
120-
if (Equals(m.symbol, m.symbol.OriginalDefinition))
120+
if (SymbolEqualityComparer.Default.Equals(m.symbol, m.symbol.OriginalDefinition))
121121
{
122122
trapFile.Write('`');
123123
trapFile.Write(m.symbol.TypeParameters.Length);
@@ -318,7 +318,7 @@ public static Method Create(Context cx, IMethodSymbol methodDecl)
318318
/// <summary>
319319
/// Whether this method has unbound type parameters.
320320
/// </summary>
321-
public bool IsUnboundGeneric => IsGeneric && Equals(symbol.ConstructedFrom, symbol);
321+
public bool IsUnboundGeneric => IsGeneric && SymbolEqualityComparer.Default.Equals(symbol.ConstructedFrom, symbol);
322322

323323
public bool IsBoundGeneric => IsGeneric && !IsUnboundGeneric;
324324

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public override bool Equals(object obj)
272272
if (other == null || other.GetType() != typeof(ConstructedExtensionParameter))
273273
return false;
274274

275-
return Equals(symbol, other.symbol) && Equals(ConstructedType, other.ConstructedType);
275+
return SymbolEqualityComparer.Default.Equals(symbol, other.symbol) && SymbolEqualityComparer.Default.Equals(ConstructedType, other.ConstructedType);
276276
}
277277

278278
public static ConstructedExtensionParameter Create(Context cx, Method method, Parameter parameter) =>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static Nullability Create(AnnotatedTypeSymbol ts)
3232

3333
public bool IsOblivious => Annotation == 0 && NullableParameters.Length == 0;
3434

35-
static readonly Nullability oblivious = new Nullability(NullableAnnotation.Disabled);
35+
static readonly Nullability oblivious = new Nullability(NullableAnnotation.None);
3636
static readonly Nullability annotated = new Nullability(NullableAnnotation.Annotated);
3737
static readonly Nullability notannotated = new Nullability(NullableAnnotation.NotAnnotated);
3838

@@ -244,14 +244,14 @@ public static AnnotatedTypeSymbol GetAnnotatedElementType(this IArrayTypeSymbol
244244
/// This has not yet been exposed on the public API.
245245
/// </summary>
246246
public static IEnumerable<AnnotatedTypeSymbol> GetAnnotatedTypeArguments(this INamedTypeSymbol symbol) =>
247-
symbol.TypeArguments.Zip(symbol.TypeArgumentsNullableAnnotations, (t, a) => new AnnotatedTypeSymbol(t, a));
247+
symbol.TypeArguments.Zip(symbol.TypeArgumentNullableAnnotations, (t, a) => new AnnotatedTypeSymbol(t, a));
248248

249249
/// <summary>
250250
/// Gets the annotated type arguments of an IMethodSymbol.
251251
/// This has not yet been exposed on the public API.
252252
/// </summary>
253253
public static IEnumerable<AnnotatedTypeSymbol> GetAnnotatedTypeArguments(this IMethodSymbol symbol) =>
254-
symbol.TypeArguments.Zip(symbol.TypeArgumentsNullableAnnotations, (t, a) => new AnnotatedTypeSymbol(t, a));
254+
symbol.TypeArguments.Zip(symbol.TypeArgumentNullableAnnotations, (t, a) => new AnnotatedTypeSymbol(t, a));
255255

256256
/// <summary>
257257
/// Gets the annotated type constraints of an ITypeParameterSymbol.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public Type(Context cx, ITypeSymbol init)
3636

3737
public static bool ConstructedOrParentIsConstructed(INamedTypeSymbol symbol)
3838
{
39-
return !Equals(symbol, symbol.OriginalDefinition) ||
39+
return !SymbolEqualityComparer.Default.Equals(symbol, symbol.OriginalDefinition) ||
4040
symbol.ContainingType != null && ConstructedOrParentIsConstructed(symbol.ContainingType);
4141
}
4242

@@ -155,7 +155,7 @@ protected void PopulateType(TextWriter trapFile)
155155
{
156156
var param = invokeMethod.Parameters[i];
157157
var originalParam = invokeMethod.OriginalDefinition.Parameters[i];
158-
var originalParamEntity = Equals(param, originalParam) ? null :
158+
var originalParamEntity = SymbolEqualityComparer.Default.Equals(param, originalParam) ? null :
159159
DelegateTypeParameter.Create(Context, originalParam, Create(Context, ((INamedTypeSymbol)symbol).OriginalDefinition));
160160
DelegateTypeParameter.Create(Context, param, this, originalParamEntity);
161161
}

csharp/extractor/Semmle.Extraction.CSharp/Semmle.Extraction.CSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</ItemGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.2.0" />
22+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" />
2323
</ItemGroup>
2424

2525
</Project>

0 commit comments

Comments
 (0)