未验证 提交 4b5650e5 编写于 作者: M msftbot[bot] 提交者: GitHub

Merge pull request #44031 from...

Merge pull request #44031 from dotnet/merges/release/dev16.7-preview1-to-release/dev16.7-preview1-vs-deps

Merge release/dev16.7-preview1 to release/dev16.7-preview1-vs-deps
......@@ -58,6 +58,9 @@ private bool ConvertExpressionToType(ExpressionSyntax expression, out NameSyntax
when ConvertExpressionToType(expr, out var leftType):
type = _syntaxFactory.QualifiedName(leftType, dotToken, simpleName);
return true;
case AliasQualifiedNameSyntax a:
type = a;
return true;
default:
return false;
};
......
......@@ -3361,6 +3361,123 @@ void M(E e)
case global::E.C: break;
}
}
}";
CreateCompilation(source, parseOptions: TestOptions.Regular7, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
CreatePatternCompilation(source, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
}
[Fact, WorkItem(44019, "https://github.com/dotnet/roslyn/issues/44019")]
public void NamespaceQualifiedEnumConstantInIsPattern_01()
{
var source =
@"enum E
{
A, B, C
}
class Class1
{
void M(object e)
{
if (e is global::E.A) { }
}
}";
CreateCompilation(source, parseOptions: TestOptions.Regular7, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
CreatePatternCompilation(source, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
}
[Fact, WorkItem(44019, "https://github.com/dotnet/roslyn/issues/44019")]
public void NamespaceQualifiedTypeInIsType_02()
{
var source =
@"enum E
{
A, B, C
}
class Class1
{
void M(object e)
{
if (e is global::E) { }
}
}";
CreateCompilation(source, parseOptions: TestOptions.Regular7, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
CreatePatternCompilation(source, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
}
[Fact, WorkItem(44019, "https://github.com/dotnet/roslyn/issues/44019")]
public void NamespaceQualifiedTypeInIsType_03()
{
var source =
@"namespace E
{
public class A { }
}
class Class1
{
void M(object e)
{
if (e is global::E.A) { }
}
}";
CreateCompilation(source, parseOptions: TestOptions.Regular7, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
CreatePatternCompilation(source, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
}
[Fact, WorkItem(44019, "https://github.com/dotnet/roslyn/issues/44019")]
public void NamespaceQualifiedTypeInIsType_04()
{
var source =
@"namespace E
{
public class A<T> { }
}
class Class1
{
void M<T>(object e)
{
if (e is global::E.A<int>) { }
if (e is global::E.A<object>) { }
if (e is global::E.A<T>) { }
}
}";
CreateCompilation(source, parseOptions: TestOptions.Regular7, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
CreatePatternCompilation(source, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
}
[Fact, WorkItem(44019, "https://github.com/dotnet/roslyn/issues/44019")]
public void NamespaceQualifiedTypeInIsType_05()
{
var source =
@"namespace E
{
public class A<T>
{
public class B { }
}
}
class Class1
{
void M<T>(object e)
{
if (e is global::E.A<int>.B) { }
if (e is global::E.A<object>.B) { }
if (e is global::E.A<T>.B) { }
}
}";
CreateCompilation(source, parseOptions: TestOptions.Regular7, options: TestOptions.ReleaseDll).VerifyDiagnostics(
);
......
......@@ -11006,5 +11006,64 @@ void verifyTree()
EOF();
}
}
[Fact, WorkItem(44019, "https://github.com/dotnet/roslyn/issues/44019")]
public void NamespaceQualifiedEnumConstantInIsPattern()
{
var source = @"_ = e is global::E.A;";
UsingStatement(source,
TestOptions.RegularWithPatternCombinators
);
verifyTree();
UsingStatement(source,
TestOptions.RegularWithoutPatternCombinators
);
verifyTree();
void verifyTree()
{
N(SyntaxKind.ExpressionStatement);
{
N(SyntaxKind.SimpleAssignmentExpression);
{
N(SyntaxKind.IdentifierName);
{
N(SyntaxKind.IdentifierToken, "_");
}
N(SyntaxKind.EqualsToken);
N(SyntaxKind.IsExpression);
{
N(SyntaxKind.IdentifierName);
{
N(SyntaxKind.IdentifierToken, "e");
}
N(SyntaxKind.IsKeyword);
N(SyntaxKind.QualifiedName);
{
N(SyntaxKind.AliasQualifiedName);
{
N(SyntaxKind.IdentifierName);
{
N(SyntaxKind.GlobalKeyword);
}
N(SyntaxKind.ColonColonToken);
N(SyntaxKind.IdentifierName);
{
N(SyntaxKind.IdentifierToken, "E");
}
}
N(SyntaxKind.DotToken);
N(SyntaxKind.IdentifierName);
{
N(SyntaxKind.IdentifierToken, "A");
}
}
}
}
N(SyntaxKind.SemicolonToken);
}
EOF();
}
}
}
}
......@@ -10,7 +10,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
{
......@@ -18,10 +17,15 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
// Analyzers should not be loaded in devenv process (see https://github.com/dotnet/roslyn/issues/43008).
internal sealed class VisualStudioAnalyzer : IDisposable
{
// Shadow copy analyzer files coming from packages to avoid locking the files in NuGet cache.
// NOTE: It is important that we share the same shadow copy assembly loader for all VisualStudioAnalyzer instances.
// This is required to ensure that shadow copied analyzer dependencies are correctly loaded.
private static readonly IAnalyzerAssemblyLoader s_analyzerAssemblyLoader =
new ShadowCopyAnalyzerAssemblyLoader(Path.Combine(Path.GetTempPath(), "VS", "AnalyzerAssemblyLoader"));
private readonly ProjectId _projectId;
private readonly HostDiagnosticUpdateSource _hostDiagnosticUpdateSource;
private readonly string _language;
private readonly IAnalyzerAssemblyLoader _analyzerAssemblyLoader;
// these 2 are mutable states that must be guarded under the _gate.
private readonly object _gate = new object();
......@@ -34,9 +38,6 @@ public VisualStudioAnalyzer(string fullPath, HostDiagnosticUpdateSource hostDiag
_hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
_projectId = projectId;
_language = language;
// Shadow copy analyzer files coming from packages to avoid locking the files in NuGet cache.
_analyzerAssemblyLoader = new ShadowCopyAnalyzerAssemblyLoader(Path.Combine(Path.GetTempPath(), "VS", "AnalyzerAssemblyLoader"));
}
public string FullPath { get; }
......@@ -50,7 +51,7 @@ public AnalyzerReference GetReference()
// TODO: ensure the file watcher is subscribed
// (tracked by https://devdiv.visualstudio.com/DevDiv/_workitems/edit/661546)
var analyzerFileReference = new AnalyzerFileReference(FullPath, _analyzerAssemblyLoader);
var analyzerFileReference = new AnalyzerFileReference(FullPath, s_analyzerAssemblyLoader);
analyzerFileReference.AnalyzerLoadFailed += OnAnalyzerLoadError;
_analyzerReference = analyzerFileReference;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册