Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into firstFix
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Feb 28, 2022
2 parents 61092f3 + 2c861cf commit 3e3e3fc
Show file tree
Hide file tree
Showing 124 changed files with 1,928 additions and 987 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<VisualStudioEditorNewPackagesVersion>17.0.487</VisualStudioEditorNewPackagesVersion>
<ILAsmPackageVersion>5.0.0-alpha1.19409.1</ILAsmPackageVersion>
<ILDAsmPackageVersion>5.0.0-preview.1.20112.8</ILDAsmPackageVersion>
<MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>17.1.11</MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>
<MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>17.2.3</MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>
<MicrosoftVisualStudioShellPackagesVersion>17.0.31723.112</MicrosoftVisualStudioShellPackagesVersion>
<RefOnlyMicrosoftBuildPackagesVersion>16.5.0</RefOnlyMicrosoftBuildPackagesVersion>
<!-- The version of Roslyn we build Source Generators against that are built in this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static void GetSubstitutedText(
writer.Write("summary");

var endGreaterThanToken = paramElement.EndTag.GreaterThanToken;
walker.VisitToken(paramElement.EndTag.GreaterThanToken);
walker.VisitToken(endGreaterThanToken);

// The '>' token doesn't own the following new line. Instead, it is directly followed by an 'XmlTextLiteralNewLineToken'.
if (endGreaterThanToken.GetNextToken() is SyntaxToken newLineToken && newLineToken.IsKind(SyntaxKind.XmlTextLiteralNewLineToken))
Expand Down
24 changes: 23 additions & 1 deletion src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10016,7 +10016,7 @@ class C
void RunWithTwoGenerators() => VerifyOutput(dir, src, includeCurrentAssemblyAsAnalyzerReference: false, additionalFlags: new[] { "/langversion:preview", "/features:enable-generator-cache" }, generators: new[] { generator.AsSourceGenerator(), generator2.AsSourceGenerator() }, driverCache: cache, analyzers: null);
}

[Fact]
[Fact(Skip = "Additional file comparison is disabled due to https://github.com/dotnet/roslyn/issues/59209")]
public void Compiler_Updates_Cached_Driver_AdditionalTexts()
{
var dir = Temp.CreateDirectory();
Expand Down Expand Up @@ -13702,6 +13702,28 @@ public void SourceGeneratorsRunRegardlessOfLanguageVersion(LanguageVersion versi
Assert.Contains("CS8785: Generator 'CallbackGenerator' failed to generate source.", output);
}

[Fact]
[WorkItem(59209, "https://github.com/dotnet/roslyn/issues/59209")]
public void SourceGenerators_Binary_Additional_File()
{
var dir = Temp.CreateDirectory();
var src = dir.CreateFile("temp.cs").WriteAllText(@"
class C
{
}");

var additionalFile = dir.CreateFile("temp.bin").WriteAllBytes(TestResources.NetFX.Minimal.mincorlib);

var generatedSource = "public class D { }";
var generator = new SingleFileTestGenerator(generatedSource, "generatedSource.cs");

VerifyOutput(dir, src, includeCurrentAssemblyAsAnalyzerReference: false, additionalFlags: new[] { "/additionalfile:" + additionalFile.Path, "/langversion:preview", "/out:embed.exe" }, generators: new[] { generator }, analyzers: null);

// Clean up temp files
CleanupAllGeneratedFiles(src.Path);
Directory.Delete(dir.Path, true);
}

[DiagnosticAnalyzer(LanguageNames.CSharp)]
private sealed class FieldAnalyzer : DiagnosticAnalyzer
{
Expand Down
19 changes: 0 additions & 19 deletions src/Compilers/CSharp/Test/Emit2/Emit2.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static class SharedInputNodes

public static readonly InputNode<ParseOptions> ParseOptions = new InputNode<ParseOptions>(b => ImmutableArray.Create(b.DriverState.ParseOptions));

public static readonly InputNode<AdditionalText> AdditionalTexts = new InputNode<AdditionalText>(b => b.DriverState.AdditionalTexts, AdditionalTextComparer.Instance);
public static readonly InputNode<AdditionalText> AdditionalTexts = new InputNode<AdditionalText>(b => b.DriverState.AdditionalTexts);

public static readonly InputNode<SyntaxTree> SyntaxTrees = new InputNode<SyntaxTree>(b => b.Compilation.SyntaxTrees.ToImmutableArray());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ public async Task<Document> AddSourceToAsync(Document document, Compilation symb
var containingOrThis = symbol.GetContainingTypeOrThis();
var fullName = GetFullReflectionName(containingOrThis);

MetadataReference metadataReference = null;
string assemblyLocation = null;
var metadataReference = symbolCompilation.GetMetadataReference(symbol.ContainingAssembly);
var assemblyLocation = (metadataReference as PortableExecutableReference)?.FilePath;

var isReferenceAssembly = symbol.ContainingAssembly.GetAttributes().Any(attribute => attribute.AttributeClass.Name == nameof(ReferenceAssemblyAttribute)
&& attribute.AttributeClass.ToNameDisplayString() == typeof(ReferenceAssemblyAttribute).FullName);
if (isReferenceAssembly)
if (isReferenceAssembly &&
!MetadataAsSourceHelpers.TryGetImplementationAssemblyPath(assemblyLocation, out assemblyLocation))
{
try
{
Expand All @@ -64,12 +66,6 @@ public async Task<Document> AddSourceToAsync(Document document, Compilation symb
}
}

if (assemblyLocation == null)
{
metadataReference = symbolCompilation.GetMetadataReference(symbol.ContainingAssembly);
assemblyLocation = (metadataReference as PortableExecutableReference)?.FilePath;
}

// Decompile
document = PerformDecompilation(document, fullName, symbolCompilation, metadataReference, assemblyLocation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class C
{
void M()
{
var v = new { P = new { Type = this.GetType(), V = this.ToString() } };
var v = new { Value = new { Type = this.GetType(), V = this.ToString() } };
}
}");
}
Expand All @@ -108,7 +108,7 @@ class C
{
void M()
{
var v = new { P = new { Type = this.GetType(), V = this.ToString() } };
var v = new { Value = new { Type = this.GetType(), V = this.ToString() } };
}
}");
}
Expand All @@ -130,7 +130,7 @@ class C
{
void M()
{
var v = new { P = new { Type = this.GetType(), Type1 = this.GetType() } };
var v = new { Value = new { Type = this.GetType(), Type1 = this.GetType() } };
}
}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void M()
@"
class C
{
public C(object p, int i) { }
public C(object value, int i) { }
}
class D
Expand Down Expand Up @@ -1068,7 +1068,6 @@ void M2()
M1(1, 2);
}
}");
//Should fix to: void M1<T>(T arg, T v) { }
}

[WorkItem(21446, "https://github.com/dotnet/roslyn/issues/21446")]
Expand Down Expand Up @@ -1199,7 +1198,7 @@ void M2()
@"
class C1
{
void M1((int, int) t1, (int, string) p)
void M1((int, int) t1, (int, string) value)
{
}
void M2()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ static void Main(string[] args)
{
System.Collections.Generic.IEnumerable<int> enumerable()
{
var vs1 = new int[] { 1, 2 };
var vs = new int[] { 3, 4 };
foreach (var num in vs1)
var ints1 = new int[] { 1, 2 };
var ints = new int[] { 3, 4 };
foreach (var num in ints1)
{
foreach (var a in new int[] { 5, 6 })
{
foreach (var x1 in vs)
foreach (var x1 in ints)
{
if (object.Equals(num, x1))
{
Expand Down Expand Up @@ -221,18 +221,18 @@ static void Main(string[] args)
{
System.Collections.Generic.IEnumerable<int> enumerable()
{
var vs2 = new int[] { 1, 2 };
var vs1 = new int[] { 3, 4 };
var vs = new int[] { 7, 8 };
foreach (var num in vs2)
var ints2 = new int[] { 1, 2 };
var ints1 = new int[] { 3, 4 };
var ints = new int[] { 7, 8 };
foreach (var num in ints2)
{
foreach (var a in new int[] { 5, 6 })
{
foreach (var x1 in vs1)
foreach (var x1 in ints1)
{
if (object.Equals(num, x1))
{
foreach (var x2 in vs)
foreach (var x2 in ints)
{
if (object.Equals(num, x2))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class C
{
void M(Action action)
{
Action {|Rename:p|} = () => { var x[||] = y; };
M(p);
Action {|Rename:value|} = () => { var x[||] = y; };
M(value);
}
}");
}
Expand Down Expand Up @@ -1450,8 +1450,8 @@ void Main()
{
void Main()
{
var {|Rename:p|} = new { A = 0 };
var a = p;
var {|Rename:value|} = new { A = 0 };
var a = value;
}
}");
}
Expand All @@ -1474,8 +1474,8 @@ static void Main(string[] args)
static void Main(string[] args)
{
int[] a = null;
var {|Rename:vs|} = a = new[] { 1, 2, 3 };
int[] temp = checked(vs);
var {|Rename:ints|} = a = new[] { 1, 2, 3 };
int[] temp = checked(ints);
}
}",
options: ImplicitTypingEverywhere());
Expand Down Expand Up @@ -1516,8 +1516,8 @@ void Main()
{
void Main()
{
var {|Rename:p|} = new { X = 1 };
WriteLine(p);
var {|Rename:value|} = new { X = 1 };
WriteLine(value);
}
}");
}
Expand Down Expand Up @@ -2567,8 +2567,8 @@ static void Main(string[] args)
{
Func<int, Func<int, int>> f = x =>
{
Func<int, int> {|Rename:p|} = y => y + 1;
return p;
Func<int, int> {|Rename:value|} = y => y + 1;
return value;
};
}
}");
Expand Down Expand Up @@ -2596,8 +2596,8 @@ static void Main(string[] args)
{
Func<int, Func<int, int>> f = x =>
{
Func<int, int> {|Rename:p|} = y => x + 1;
return p;
Func<int, int> {|Rename:value|} = y => x + 1;
return value;
};
}
}");
Expand Down Expand Up @@ -4964,8 +4964,8 @@ public async Task Tuple_TuplesDisabled()
var expected =
@"class C
{
private static readonly (int, string) {|Rename:p|} = (1, ""hello"");
var i = p.ToString();
private static readonly (int, string) {|Rename:value|} = (1, ""hello"");
var i = value.ToString();
}";

await TestAsync(code, expected, parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp6));
Expand Down Expand Up @@ -5003,8 +5003,8 @@ public async Task Tuple_IntroduceConstant()
var expected =
@"class C
{
private static readonly (int, string) {|Rename:p|} = (1, ""hello"");
var i = p.ToString();
private static readonly (int, string) {|Rename:value|} = (1, ""hello"");
var i = value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected);
Expand All @@ -5022,8 +5022,8 @@ public async Task TupleWithNames_IntroduceConstant()
var expected =
@"class C
{
private static readonly (int a, string b) {|Rename:p|} = (a: 1, b: ""hello"");
var i = p.ToString();
private static readonly (int a, string b) {|Rename:value|} = (a: 1, b: ""hello"");
var i = value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected);
Expand All @@ -5041,8 +5041,8 @@ public async Task Tuple_IntroduceConstantForAllOccurrences()
var expected =
@"class C
{
private static readonly (int, string) {|Rename:p|} = (1, ""hello"");
var i = p.ToString() + p.ToString();
private static readonly (int, string) {|Rename:value|} = (1, ""hello"");
var i = value.ToString() + value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected, index: 1);
Expand All @@ -5060,8 +5060,8 @@ public async Task TupleWithNames_IntroduceConstantForAllOccurrences()
var expected =
@"class C
{
private static readonly (int a, string b) {|Rename:p|} = (a: 1, b: ""hello"");
var i = p.ToString() + p.ToString();
private static readonly (int a, string b) {|Rename:value|} = (a: 1, b: ""hello"");
var i = value.ToString() + value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected, index: 1);
Expand All @@ -5079,8 +5079,8 @@ public async Task TupleWithDifferentNames_IntroduceConstantForAllOccurrences()
var expected =
@"class C
{
private static readonly (int a, string b) {|Rename:p|} = (a: 1, b: ""hello"");
var i = p.ToString() + (c: 1, d: ""hello"").ToString();
private static readonly (int a, string b) {|Rename:value|} = (a: 1, b: ""hello"");
var i = value.ToString() + (c: 1, d: ""hello"").ToString();
}";

await TestInRegularAndScriptAsync(code, expected, index: 1);
Expand All @@ -5098,8 +5098,8 @@ public async Task TupleWithOneName_IntroduceConstantForAllOccurrences()
var expected =
@"class C
{
private static readonly (int a, string) {|Rename:p|} = (a: 1, ""hello"");
var i = p.ToString() + p.ToString();
private static readonly (int a, string) {|Rename:value|} = (a: 1, ""hello"");
var i = value.ToString() + value.ToString();
}";

await TestInRegularAndScriptAsync(code, expected, index: 1);
Expand Down Expand Up @@ -6074,8 +6074,8 @@ class C
byte[] getArray() => null;
void test()
{
byte[] {|Rename:vs|} = getArray();
var goo = vs[0];
byte[] {|Rename:bytes|} = getArray();
var goo = bytes[0];
}
}");
}
Expand Down
Loading

0 comments on commit 3e3e3fc

Please sign in to comment.