diff --git a/src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs b/src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs index 91a8d9abe21e4f1dbff6deddaa6dc55a776f1c93..19797bd4e5cec1884cec28eedc8aea29cdff4cf4 100644 --- a/src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs +++ b/src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs @@ -632,7 +632,8 @@ public override AwaitExpressionInfo GetAwaitExpressionInfo(AwaitExpressionSyntax throw new ArgumentException("node.Kind==" + node.Kind()); } - BoundAwaitExpression boundAwait = GetUpperBoundNode(node) as BoundAwaitExpression; + var bound = GetUpperBoundNode(node); + BoundAwaitExpression boundAwait = ((bound as BoundExpressionStatement)?.Expression ?? bound) as BoundAwaitExpression; if (boundAwait == null) { return default(AwaitExpressionInfo); diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_StringInterpolation.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_StringInterpolation.cs index 0dd84820bcf7ab1276522cf15d89c685dbc4136b..b3400bc60f2b03808f4763fa78d4455820a4ba71 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_StringInterpolation.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_StringInterpolation.cs @@ -64,7 +64,13 @@ private void MakeInterpolatedStringFormat(BoundInterpolatedString node, out Boun formatString.Builder.Append(":").Append(fillin.Format.ConstantValue.StringValue); } formatString.Builder.Append("}"); - expressions.Add(fillin.Value); // NOTE: must still be lowered + var value = fillin.Value; + if (value.Type?.TypeKind == TypeKind.Dynamic) + { + value = MakeConversion(value, _compilation.ObjectType, @checked: false); + } + + expressions.Add(value); // NOTE: must still be lowered } } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs index 09a31b4a0411a29c68f342d88b799161173c29ba..b358beb887b87dae2b720a84e7c671945fc84cba 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/AwaitExpressionTests.cs @@ -35,6 +35,24 @@ async void Foo(Task t) Assert.Equal("System.Boolean System.Runtime.CompilerServices.TaskAwaiter.IsCompleted { get; }", info.IsCompletedProperty.ToTestDisplayString()); } + [Fact] + [WorkItem(1084696, "DevDiv")] + public void TestAwaitInfo2() + { + var text = +@"using System; +using System.Threading.Tasks; +public class C { + public C(Task t) { + Func f = async() => await t; + } +}"; + var info = GetAwaitExpressionInfo(text); + Assert.Equal("System.Runtime.CompilerServices.TaskAwaiter System.Threading.Tasks.Task.GetAwaiter()", info.GetAwaiterMethod.ToTestDisplayString()); + Assert.Equal("System.Int32 System.Runtime.CompilerServices.TaskAwaiter.GetResult()", info.GetResultMethod.ToTestDisplayString()); + Assert.Equal("System.Boolean System.Runtime.CompilerServices.TaskAwaiter.IsCompleted { get; }", info.IsCompletedProperty.ToTestDisplayString()); + } + private AwaitExpressionInfo GetAwaitExpressionInfo(string text, params DiagnosticDescription[] diagnostics) { var tree = Parse(text, options: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp5)); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs index 2b39efdc87c461f4800781d4629bdfca161272d2..30f5cb2724ad1f8d22c9d5d2441aa738998f7f5d 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs @@ -248,6 +248,30 @@ static void Main(string[] args) CompileAndVerify(source, expectedOutput: expectedOutput); } + [Fact, WorkItem(306), WorkItem(308)] + public void DynamicInterpolation() + { + string source = +@"using System; +using System.Linq.Expressions; +class Program +{ + static void Main(string[] args) + { + dynamic nil = null; + dynamic a = new string[] {""Hello"", ""world""}; + Console.WriteLine($""<{nil}>""); + Console.WriteLine($""<{a}>""); + } + Expression> M(dynamic d) { + return () => $""Dynamic: {d}""; + } +}"; + string expectedOutput = @"<> +"; + var verifier = CompileAndVerify(source, new[] { SystemCoreRef, CSharpRef }, expectedOutput: expectedOutput).VerifyDiagnostics(); + } + [Fact] public void UnclosedInterpolation01() { diff --git a/src/Compilers/Core/Desktop/FileKey.cs b/src/Compilers/Core/Desktop/FileKey.cs index 52c992395504dfde469996b9d655f992f5f65d91..47f18267c8ea8217f32fb3cd797dc88f1bea6633 100644 --- a/src/Compilers/Core/Desktop/FileKey.cs +++ b/src/Compilers/Core/Desktop/FileKey.cs @@ -26,6 +26,7 @@ internal struct FileKey : IEquatable public FileKey(string fullPath, DateTime timestamp) { Debug.Assert(PathUtilities.IsAbsolute(fullPath)); + Debug.Assert(timestamp.Kind == DateTimeKind.Utc); FullPath = fullPath; Timestamp = timestamp; diff --git a/src/Compilers/Core/VBCSCompiler/MetadataCache.cs b/src/Compilers/Core/VBCSCompiler/MetadataCache.cs index 7859b00c2a18c99bc67ef505be6fc03145ef6269..db2d652e107086a332525a9afe6cc236fc720c53 100644 --- a/src/Compilers/Core/VBCSCompiler/MetadataCache.cs +++ b/src/Compilers/Core/VBCSCompiler/MetadataCache.cs @@ -83,9 +83,9 @@ internal Metadata GetMetadata(string fullPath, MetadataReferenceProperties prope } /// - /// A unique file key encapsulates a file path, and change date as - /// hat can be used as the key to a dictionary. - /// If a file hasn't changed name or change date, we assume + /// A unique file key encapsulates a file path, and change date + /// that can be used as the key to a dictionary. + /// If a file hasn't changed name or timestamp, we assume /// it is unchanged. /// /// Returns null if the file doesn't exist or otherwise can't be accessed. @@ -104,7 +104,7 @@ internal Metadata GetMetadata(string fullPath, MetadataReferenceProperties prope } else { - return new FileKey(fileInfo.FullName, fileInfo.LastWriteTime); + return new FileKey(fileInfo.FullName, fileInfo.LastWriteTimeUtc); } } catch (Exception) diff --git a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs index 1e73a3c61403f7d92523c84baa40064e12abf237..d03e168d4ce7bc7f8d52684e7d225e0ede7ac799 100644 --- a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs +++ b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.DeclaredSymbolNavigableItem.cs @@ -23,12 +23,14 @@ internal class DeclaredSymbolNavigableItem : INavigableItem private readonly Lazy _lazyDisplayName; private readonly Lazy _lazySymbol; - public DeclaredSymbolNavigableItem(Document document, DeclaredSymbolInfo declaredSymbolInfo, CancellationToken cancellationToken) + public DeclaredSymbolNavigableItem(Document document, DeclaredSymbolInfo declaredSymbolInfo) { Document = document; _declaredSymbolInfo = declaredSymbolInfo; - _lazySymbol = new Lazy(() => declaredSymbolInfo.GetSymbolAsync(document, cancellationToken).ConfigureAwait(false).GetAwaiter().GetResult()); + // Cancellation isn't supported when computing the various properties that depend on the symbol, hence + // CancellationToken.None. + _lazySymbol = new Lazy(() => declaredSymbolInfo.GetSymbolAsync(document, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult()); _lazyDisplayName = new Lazy(() => { if (Symbol == null) diff --git a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.cs b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.cs index 5ff90563df8c489882e76a9b77940a09590c4ee0..bdc896a16976749932c54e14c554d89287f08ce6 100644 --- a/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.cs +++ b/src/EditorFeatures/Core/Extensibility/Navigation/NavigableItemFactory.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; -using System.Threading; using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.GeneratedCodeRecognition; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -17,9 +16,9 @@ public static INavigableItem GetItemFromSymbolLocation(Solution solution, ISymbo return new SymbolLocationNavigableItem(solution, symbol, location); } - public static INavigableItem GetItemFromDeclaredSymbolInfo(DeclaredSymbolInfo declaredSymbolInfo, Document document, CancellationToken cancellationToken) + public static INavigableItem GetItemFromDeclaredSymbolInfo(DeclaredSymbolInfo declaredSymbolInfo, Document document) { - return new DeclaredSymbolNavigableItem(document, declaredSymbolInfo, cancellationToken); + return new DeclaredSymbolNavigableItem(document, declaredSymbolInfo); } public static IEnumerable GetItemsfromPreferredSourceLocations(Solution solution, ISymbol symbol) diff --git a/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.SearchResult.cs b/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.SearchResult.cs index 9fae74f4e6566f518fb2adf68dd265a3d5f8565c..284084f354227c20e2c19e667aa77a8d386a31c2 100644 --- a/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.SearchResult.cs +++ b/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.SearchResult.cs @@ -41,7 +41,7 @@ public SearchResult(Document document, DeclaredSymbolInfo declaredSymbolInfo, st var declaredNavigableItem = navigableItem as NavigableItemFactory.DeclaredSymbolNavigableItem; Debug.Assert(declaredNavigableItem != null); - _lazySummary = new Lazy(() => declaredNavigableItem.Symbol.GetDocumentationComment()?.SummaryText); + _lazySummary = new Lazy(() => declaredNavigableItem.Symbol?.GetDocumentationComment()?.SummaryText); _lazyAdditionalInfo = new Lazy(() => { switch (declaredSymbolInfo.Kind) diff --git a/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.cs b/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.cs index 2a020127927f06856fe8ceb584db6565e3ac13cf..ef6bca88ccb3ce76bccd21956b0c2aa8e1e27c57 100644 --- a/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.cs +++ b/src/EditorFeatures/Core/Implementation/NavigateTo/AbstractNavigateToSearchService.cs @@ -17,10 +17,10 @@ internal abstract partial class AbstractNavigateToSearchService : INavigateToSea public async Task> SearchProjectAsync(Project project, string searchPattern, CancellationToken cancellationToken) { var results = await NavigateToSymbolFinder.FindNavigableDeclaredSymbolInfos(project, searchPattern, cancellationToken).ConfigureAwait(false); - return results.Select(r => ConvertResult(r, cancellationToken)); + return results.Select(r => ConvertResult(r)); } - private INavigateToSearchResult ConvertResult(ValueTuple> result, CancellationToken cancellationToken) + private INavigateToSearchResult ConvertResult(ValueTuple> result) { var declaredSymbolInfo = result.Item1; var document = result.Item2; @@ -31,7 +31,7 @@ private INavigateToSearchResult ConvertResult(ValueTuple m.IsCaseSensitive); var kind = GetItemKind(declaredSymbolInfo); - var navigableItem = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document, cancellationToken); + var navigableItem = NavigableItemFactory.GetItemFromDeclaredSymbolInfo(declaredSymbolInfo, document); return new SearchResult(document, declaredSymbolInfo, kind, matchKind, isCaseSensitive, navigableItem); } diff --git a/src/Roslyn.sln b/src/Roslyn.sln index 2b7e89616b83cffd5d2067be551cc8637a04461a..1571801a89041e8d5c1710b091f22e814cbe301f 100644 --- a/src/Roslyn.sln +++ b/src/Roslyn.sln @@ -281,14 +281,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualStudio", "VisualStudi EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Diagnostics", "Diagnostics", "{5F5DD61A-746D-40AE-A89C-EF82B39C036E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeAnalysis", "CodeAnalysis", "{2344BE45-7F6B-4A4E-9418-567FA2D9CA8C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisDiagnosticAnalyzers", "Diagnostics\CodeAnalysis\Core\CodeAnalysisDiagnosticAnalyzers.csproj", "{D8762A0A-3832-47BE-BCF6-8B1060BE6B28}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpCodeAnalysisDiagnosticAnalyzers", "Diagnostics\CodeAnalysis\CSharp\CSharpCodeAnalysisDiagnosticAnalyzers.csproj", "{921B412A-5551-4853-82B4-46AD5A05A03E}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BasicCodeAnalysisDiagnosticAnalyzers", "Diagnostics\CodeAnalysis\VisualBasic\BasicCodeAnalysisDiagnosticAnalyzers.vbproj", "{B1A6A74B-E484-48FB-8745-7A30A06DB631}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisDiagnosticAnalyzersTest", "Diagnostics\CodeAnalysis\Test\CodeAnalysisDiagnosticAnalyzersTest.csproj", "{0C2925AD-CD97-46FA-A686-E2C1AD19DAD8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysisDiagnosticsSetup", "Diagnostics\CodeAnalysis\Setup\CodeAnalysisDiagnosticsSetup.csproj", "{54F6AE18-B0CD-4799-9DF0-9B1AAD6A78AF}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{edc68a0e-c68d-4a74-91b7-bf38ec909888}*SharedItemsImports = 4 Compilers\Core\SharedCollections\SharedCollections.projitems*{5f8d2414-064a-4b3a-9b42-8e2a04246be5}*SharedItemsImports = 4 Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 4 Compilers\Core\SharedCollections\SharedCollections.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4 - Compilers\Core\SharedCollections\SharedCollections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 + Compilers\Core\SharedCollections\SharedCollections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4 Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 4 Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 4 Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 4 @@ -770,6 +782,26 @@ Global {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D8762A0A-3832-47BE-BCF6-8B1060BE6B28}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D8762A0A-3832-47BE-BCF6-8B1060BE6B28}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D8762A0A-3832-47BE-BCF6-8B1060BE6B28}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D8762A0A-3832-47BE-BCF6-8B1060BE6B28}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {921B412A-5551-4853-82B4-46AD5A05A03E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {921B412A-5551-4853-82B4-46AD5A05A03E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {921B412A-5551-4853-82B4-46AD5A05A03E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {921B412A-5551-4853-82B4-46AD5A05A03E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B1A6A74B-E484-48FB-8745-7A30A06DB631}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {B1A6A74B-E484-48FB-8745-7A30A06DB631}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B1A6A74B-E484-48FB-8745-7A30A06DB631}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {B1A6A74B-E484-48FB-8745-7A30A06DB631}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {0C2925AD-CD97-46FA-A686-E2C1AD19DAD8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {0C2925AD-CD97-46FA-A686-E2C1AD19DAD8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {0C2925AD-CD97-46FA-A686-E2C1AD19DAD8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {0C2925AD-CD97-46FA-A686-E2C1AD19DAD8}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {54F6AE18-B0CD-4799-9DF0-9B1AAD6A78AF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {54F6AE18-B0CD-4799-9DF0-9B1AAD6A78AF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {54F6AE18-B0CD-4799-9DF0-9B1AAD6A78AF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {54F6AE18-B0CD-4799-9DF0-9B1AAD6A78AF}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -899,5 +931,11 @@ Global {5002636A-FE8D-40BF-8818-AB513A2194FA} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {ABDBAC1E-350E-4DC3-BB45-3504404545EE} = {235A3418-A3B0-4844-BCEB-F1CF45069232} {BEDC5A4A-809E-4017-9CFD-6C8D4E1847F0} = {235A3418-A3B0-4844-BCEB-F1CF45069232} + {2344BE45-7F6B-4A4E-9418-567FA2D9CA8C} = {5F5DD61A-746D-40AE-A89C-EF82B39C036E} + {D8762A0A-3832-47BE-BCF6-8B1060BE6B28} = {2344BE45-7F6B-4A4E-9418-567FA2D9CA8C} + {921B412A-5551-4853-82B4-46AD5A05A03E} = {2344BE45-7F6B-4A4E-9418-567FA2D9CA8C} + {B1A6A74B-E484-48FB-8745-7A30A06DB631} = {2344BE45-7F6B-4A4E-9418-567FA2D9CA8C} + {0C2925AD-CD97-46FA-A686-E2C1AD19DAD8} = {2344BE45-7F6B-4A4E-9418-567FA2D9CA8C} + {54F6AE18-B0CD-4799-9DF0-9B1AAD6A78AF} = {2344BE45-7F6B-4A4E-9418-567FA2D9CA8C} EndGlobalSection EndGlobal diff --git a/src/VisualStudio/Core/SolutionExplorerShim/AnalyzersCommandHandler.cs b/src/VisualStudio/Core/SolutionExplorerShim/AnalyzersCommandHandler.cs index 803c95ff8310107b07a7ea447e15eda7d61f396d..dc2b34b54e4a966e5b59812938f55418ca97afa7 100644 --- a/src/VisualStudio/Core/SolutionExplorerShim/AnalyzersCommandHandler.cs +++ b/src/VisualStudio/Core/SolutionExplorerShim/AnalyzersCommandHandler.cs @@ -13,6 +13,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Host; using Microsoft.CodeAnalysis.Notification; +using Microsoft.VisualStudio.CodeAnalysis; using Microsoft.VisualStudio.ComponentModelHost; using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem; using Microsoft.VisualStudio.LanguageServices.SolutionExplorer; @@ -266,7 +267,7 @@ private void SetSeverityHandler(object sender, EventArgs args) EnvDTE.Project envDteProject; project.Hierarchy.TryGetProject(out envDteProject); - if (IsBuiltInRuleSet(pathToRuleSet)) + if (SdkUiUtilities.IsBuiltInRuleSet(pathToRuleSet, _serviceProvider)) { pathToRuleSet = CreateCopyOfRuleSetForProject(pathToRuleSet, envDteProject); if (pathToRuleSet == null) @@ -489,44 +490,5 @@ private Workspace TryGetWorkspace() return _workspace; } - - private bool IsBuiltInRuleSet(string pathToRuleSet) - { - if (string.IsNullOrEmpty(pathToRuleSet)) - { - return false; - } - - // Canonicalize and compare - string ruleSetInBuiltInDirectory = Path.Combine(GetBuiltInRuleSetDirectory(_serviceProvider), Path.GetFileName(pathToRuleSet)); - if (ruleSetInBuiltInDirectory.Equals(Path.GetFullPath(pathToRuleSet), StringComparison.OrdinalIgnoreCase)) - { - FileInfo ruleSetFile = new FileInfo(pathToRuleSet); - if ((ruleSetFile.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) - { - return true; - } - } - - return false; - } - - private string GetBuiltInRuleSetDirectory(IServiceProvider serviceProvider) - { - return Path.Combine(GetStaticAnalysisToolsDirectory(serviceProvider), "Rule Sets"); - } - - private string GetStaticAnalysisToolsDirectory(IServiceProvider serviceProvider) - { - string installDirectory = null; - - // Get the VS install directory - IVsShell shell = (IVsShell)serviceProvider.GetService(typeof(IVsShell)); - object value; - Marshal.ThrowExceptionForHR(shell.GetProperty((int)__VSSPROPID2.VSSPROPID_InstallRootDir, out value)); - installDirectory = (string)value; - - return Path.Combine(installDirectory, "Team Tools", "Static Analysis Tools"); - } } } diff --git a/src/VisualStudio/Core/SolutionExplorerShim/SolutionExplorerShim.csproj b/src/VisualStudio/Core/SolutionExplorerShim/SolutionExplorerShim.csproj index 99c0893a5f4e473d5d377e3eafc388b55120818c..fe842d53e7859f864af4e9deb52170dfa5533d78 100644 --- a/src/VisualStudio/Core/SolutionExplorerShim/SolutionExplorerShim.csproj +++ b/src/VisualStudio/Core/SolutionExplorerShim/SolutionExplorerShim.csproj @@ -25,6 +25,9 @@ True + + $(DevEnvDir)\PrivateAssemblies\Microsoft.VisualStudio.CodeAnalysis.Sdk.UI.dll +