Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8adbfda

Browse files
authored
Merge pull request #1275 from calumgrant/cs/roslyn-3.0.0
C#: Update nuget packages
2 parents d23c483 + c28fa7e commit 8adbfda

10 files changed

Lines changed: 72 additions & 41 deletions

File tree

csharp/autobuilder/Semmle.Autobuild.Tests/Semmle.Autobuild.Tests.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="xunit" Version="2.4.0" />
11-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
10+
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
11+
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
12+
<PackageReference Include="xunit" Version="2.4.1" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
16+
</PackageReference>
1217
</ItemGroup>
1318

1419
<ItemGroup>

csharp/autobuilder/Semmle.Autobuild/Semmle.Autobuild.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.Build" Version="15.8.166" />
19-
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
19+
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

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

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,43 @@ namespace Semmle.Extraction.CSharp.Entities.Expressions
88
{
99
class IsPattern : Expression<IsPatternExpressionSyntax>
1010
{
11-
IsPattern(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.IS))
11+
private IsPattern(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.IS))
1212
{
1313
}
1414

15-
protected override void Populate()
15+
private void PopulatePattern(PatternSyntax pattern, TypeSyntax optionalType, SyntaxToken varKeyword, VariableDesignationSyntax designation)
1616
{
17-
var constantPattern = Syntax.Pattern as ConstantPatternSyntax;
18-
if (constantPattern != null)
17+
bool isVar = optionalType is null;
18+
if (!isVar)
19+
Expressions.TypeAccess.Create(cx, optionalType, this, 1);
20+
21+
if (cx.Model(pattern).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
1922
{
20-
Create(cx, Syntax.Expression, this, 0);
21-
Create(cx, constantPattern.Expression, this, 3);
22-
return;
23-
}
23+
var type = Type.Create(cx, symbol.Type);
2424

25-
var pattern = Syntax.Pattern as DeclarationPatternSyntax;
25+
if (isVar)
26+
new Expression(new ExpressionInfo(cx, type, cx.Create(varKeyword.GetLocation()), ExprKind.TYPE_ACCESS, this, 1, false, null));
2627

27-
if (pattern == null)
28-
{
29-
throw new InternalError(Syntax, "Is-pattern not handled");
28+
VariableDeclaration.Create(cx, symbol, type, cx.Create(pattern.GetLocation()), cx.Create(designation.GetLocation()), isVar, this, 2);
3029
}
30+
}
3131

32+
protected override void Populate()
33+
{
3234
Create(cx, Syntax.Expression, this, 0);
33-
TypeAccess.Create(cx, pattern.Type, this, 1);
34-
35-
var symbol = cx.Model(Syntax).GetDeclaredSymbol(pattern.Designation) as ILocalSymbol;
36-
if (symbol != null)
35+
switch (Syntax.Pattern)
3736
{
38-
var type = Type.Create(cx, symbol.Type);
39-
var isVar = pattern.Type.IsVar;
40-
VariableDeclaration.Create(cx, symbol, type, cx.Create(pattern.GetLocation()), cx.Create(pattern.Designation.GetLocation()), isVar, this, 2);
37+
case ConstantPatternSyntax constantPattern:
38+
Create(cx, constantPattern.Expression, this, 3);
39+
return;
40+
case VarPatternSyntax varPattern:
41+
PopulatePattern(varPattern, null, varPattern.VarKeyword, varPattern.Designation);
42+
return;
43+
case DeclarationPatternSyntax declPattern:
44+
PopulatePattern(declPattern, declPattern.Type, default(SyntaxToken), declPattern.Designation);
45+
return;
46+
default:
47+
throw new InternalError(Syntax, "Is pattern not handled");
4148
}
4249
}
4350

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,9 @@ public static void ExtractModifiers(Context cx, IEntity key, ISymbol symbol)
142142
// Sadly, these properties are internal so cannot be accessed directly.
143143
// This seems to be a deficiency in the model.
144144
var readonlyProperty = nt.GetType().GetProperty("IsReadOnly", BindingFlags.NonPublic | BindingFlags.Instance);
145-
var isByRefProperty = nt.GetType().GetProperty("IsByRefLikeType", BindingFlags.NonPublic | BindingFlags.Instance);
146145

147146
bool isReadOnly = (bool)readonlyProperty.GetValue(nt);
148-
bool isByRefLikeType = (bool)isByRefProperty.GetValue(nt);
147+
bool isByRefLikeType = nt.IsRefLikeType;
149148

150149
if (isReadOnly)
151150
HasModifier(cx, key, "readonly");

csharp/extractor/Semmle.Extraction.CSharp/Entities/Statements/Case.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,35 @@ public static CaseDefault Create(Context cx, DefaultSwitchLabelSyntax node, Swit
6464

6565
class CasePattern : Case<CasePatternSwitchLabelSyntax>
6666
{
67-
CasePattern(Context cx, CasePatternSwitchLabelSyntax node, Switch parent, int child)
67+
private CasePattern(Context cx, CasePatternSwitchLabelSyntax node, Switch parent, int child)
6868
: base(cx, node, parent, child) { }
6969

70+
private void PopulatePattern(PatternSyntax pattern, TypeSyntax optionalType, SyntaxToken varKeyword, VariableDesignationSyntax designation)
71+
{
72+
var isVar = optionalType is null;
73+
if(!isVar)
74+
Expressions.TypeAccess.Create(cx, optionalType, this, 1);
75+
76+
if (cx.Model(pattern).GetDeclaredSymbol(designation) is ILocalSymbol symbol)
77+
{
78+
var type = Type.Create(cx, symbol.Type);
79+
80+
if (isVar)
81+
new Expression(new ExpressionInfo(cx, type, cx.Create(varKeyword.GetLocation()), ExprKind.TYPE_ACCESS, this, 1, false, null));
82+
83+
Expressions.VariableDeclaration.Create(cx, symbol, type, cx.Create(pattern.GetLocation()), cx.Create(designation.GetLocation()), isVar, this, 0);
84+
}
85+
}
86+
7087
protected override void Populate()
7188
{
7289
switch(Stmt.Pattern)
7390
{
91+
case VarPatternSyntax varPattern:
92+
PopulatePattern(varPattern, null, varPattern.VarKeyword, varPattern.Designation);
93+
break;
7494
case DeclarationPatternSyntax declarationPattern:
75-
var symbol = cx.Model(Stmt).GetDeclaredSymbol(declarationPattern.Designation) as ILocalSymbol;
76-
if (symbol != null)
77-
{
78-
var type = Type.Create(cx, symbol.Type);
79-
var isVar = declarationPattern.Type.IsVar;
80-
Expressions.VariableDeclaration.Create(cx, symbol, type, cx.Create(declarationPattern.GetLocation()), cx.Create(declarationPattern.Designation.GetLocation()), isVar, this, 0);
81-
}
82-
83-
Expressions.TypeAccess.Create(cx, declarationPattern.Type, this, 1);
95+
PopulatePattern(declarationPattern, declarationPattern.Type, default(SyntaxToken), declarationPattern.Designation);
8496
break;
8597
case ConstantPatternSyntax pattern:
8698
Expression.Create(cx, pattern.Expression, this, 0);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void Populate()
3636
var nts = (NullableTypeSyntax)Syntax;
3737
var nt = (NamedType)Type;
3838
Emit(Loc ?? Syntax.GetLocation(), Parent, Type);
39-
Create(cx, nts.ElementType, this, nt.TypeArguments[0]);
39+
Create(cx, nts.ElementType, this, nt.symbol.IsReferenceType ? nt : nt.TypeArguments[0]);
4040
return;
4141
case SyntaxKind.TupleType:
4242
var tts = (TupleTypeSyntax)Syntax;

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="2.8.0" />
22+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.0.0" />
2323
</ItemGroup>
2424

2525
</Project>

csharp/extractor/Semmle.Extraction.Tests/Semmle.Extraction.Tests.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="xunit" Version="2.4.0" />
11-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
10+
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
11+
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
12+
<PackageReference Include="xunit" Version="2.4.1" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
16+
</PackageReference>
1217
</ItemGroup>
1318

1419
<ItemGroup>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.8.0" />
15+
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.0.0" />
1616
<PackageReference Include="GitInfo" Version="2.0.18" />
1717
</ItemGroup>
1818

csharp/extractor/Semmle.Util.Tests/Semmle.Util.Tests.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="xunit" Version="2.4.0" />
11-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
10+
<PackageReference Include="xunit" Version="2.4.1" />
11+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
14+
</PackageReference>
1215
</ItemGroup>
1316

1417
<ItemGroup>

0 commit comments

Comments
 (0)