提交 b8bea03f 编写于 作者: J Jason Malinowski

Remove CSharpProject from the CSharpProjectShim* inheritence hierarchy

As best I can tell digging through source control history, this type
was some leftover remnants from a refactoring when we split out the
project system shims into "parts that talk to the project system" and
"parts that directly talk to the workspace" when we originally
implemented Code Lens. The code today resulted in having a non-abstract
class that had exactly one derived type, was never created directly
anywhere, and had bunch of methods with suspect implementations that
were never called since they were overridden in other places. This
simply deletes the intermediate type from the hierarchy and moves
stuff to the derived type.
上级 67b91a40
......@@ -44,7 +44,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService
[ProvideAutomationProperties("TextEditor", "CSharp-Specific", packageGuid: Guids.CSharpPackageIdString, profileNodeLabelId: 104, profileNodeDescriptionId: 105)]
[ProvideService(typeof(CSharpLanguageService), ServiceName = "C# Language Service")]
[ProvideService(typeof(ICSharpTempPECompilerService), ServiceName = "C# TempPE Compiler Service")]
internal class CSharpPackage : AbstractPackage<CSharpPackage, CSharpLanguageService, CSharpProject>, IVsUserSettingsQuery
internal class CSharpPackage : AbstractPackage<CSharpPackage, CSharpLanguageService, CSharpProjectShim>, IVsUserSettingsQuery
{
private ObjectBrowserLibraryManager _libraryManager;
private uint _libraryManagerCookie;
......
......@@ -246,7 +246,6 @@
</Compile>
<Compile Include="Progression\CSharpGraphProvider.cs" />
<Compile Include="Progression\CSharpProgressionLanguageService.cs" />
<Compile Include="ProjectSystemShim\CSharpProject.cs" />
<Compile Include="ProjectSystemShim\CSharpProjectShim.cs" />
<Compile Include="ProjectSystemShim\CSharpProjectShim.ICSCompiler.cs" />
<Compile Include="ProjectSystemShim\CSharpProjectShim.ICSCompilerConfig.cs" />
......
......@@ -19,7 +19,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService
{
[ExcludeFromCodeCoverage]
[Guid(Guids.CSharpLanguageServiceIdString)]
internal partial class CSharpLanguageService : AbstractLanguageService<CSharpPackage, CSharpLanguageService, CSharpProject>
internal partial class CSharpLanguageService : AbstractLanguageService<CSharpPackage, CSharpLanguageService, CSharpProjectShim>
{
internal CSharpLanguageService(CSharpPackage package)
: base(package)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Concurrent;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TextManager.Interop;
namespace Microsoft.VisualStudio.LanguageServices.CSharp.ProjectSystemShim
{
/// <summary>
/// The representation of a project to both the project factory and workspace API.
/// </summary>
/// <remarks>
/// Due to the number of interfaces this object must implement, all interface implementations
/// are in a separate files. Methods that are shared across multiple interfaces (which are
/// effectively methods that just QI from one interface to another), are implemented here.
/// </remarks>
internal partial class CSharpProject : AbstractEncProject
{
private static readonly CSharpCompilationOptions s_defaultCompilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary);
private static readonly CSharpParseOptions s_defaultParseOptions = new CSharpParseOptions();
protected CSharpProject(
VisualStudioProjectTracker projectTracker,
Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
string projectSystemName,
IVsHierarchy hierarchy,
IServiceProvider serviceProvider,
MiscellaneousFilesWorkspace miscellaneousFilesWorkspaceOpt,
VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
: base(projectTracker,
reportExternalErrorCreatorOpt,
projectSystemName,
hierarchy,
LanguageNames.CSharp,
serviceProvider,
miscellaneousFilesWorkspaceOpt,
visualStudioWorkspaceOpt,
hostDiagnosticUpdateSourceOpt)
{
InitializeOptions();
projectTracker.AddProject(this);
}
protected virtual void InitializeOptions()
{
this.SetOptions(this.CreateCompilationOptions(), this.CreateParseOptions());
}
protected virtual CSharpCompilationOptions CreateCompilationOptions()
{
return s_defaultCompilationOptions;
}
protected virtual CSharpParseOptions CreateParseOptions()
{
return s_defaultParseOptions;
}
protected override void UpdateAnalyzerRules()
{
base.UpdateAnalyzerRules();
this.SetOptions(this.CreateCompilationOptions(), this.CreateParseOptions());
}
}
}
......@@ -17,7 +17,7 @@ public void AddReferenceToCodeDirectory(string assemblyFileName, ICSharpProjectR
public void RemoveReferenceToCodeDirectory(string assemblyFileName, ICSharpProjectRoot project)
{
CSharpProject projectSite = GetProjectSite(project);
CSharpProjectShim projectSite = GetProjectSite(project);
if (!this.CurrentProjectReferencesContains(projectSite.Id))
{
......@@ -39,14 +39,14 @@ public void OnDiskFileUpdated(string filename, ref System.Runtime.InteropService
public void OnCodeDirectoryAliasesChanged(ICSharpProjectRoot project, int previousAliasesCount, string[] previousAliases, int currentAliasesCount, string[] currentAliases)
{
CSharpProject projectSite = GetProjectSite(project);
CSharpProjectShim projectSite = GetProjectSite(project);
UpdateProjectReferenceAliases(projectSite, ImmutableArray.Create(currentAliases));
}
public void AddReferenceToCodeDirectoryEx(string assemblyFileName, ICSharpProjectRoot project, CompilerOptions optionID)
{
CSharpProject projectSite = GetProjectSite(project);
CSharpProjectShim projectSite = GetProjectSite(project);
AddProjectReference(new ProjectReference(projectSite.Id));
}
......@@ -55,11 +55,11 @@ public void AddReferenceToCodeDirectoryEx(string assemblyFileName, ICSharpProjec
/// Given a ICSharpProjectRoot instance, it returns the ProjectSite instance, throwing if it
/// could not be obtained.
/// </summary>
private static CSharpProject GetProjectSite(ICSharpProjectRoot project)
private static CSharpProjectShim GetProjectSite(ICSharpProjectRoot project)
{
// Get the host back for the project
Guid projectSiteGuid = typeof(ICSharpProjectSite).GUID;
CSharpProject projectSite = project.GetProjectSite(ref projectSiteGuid) as CSharpProject;
CSharpProjectShim projectSite = project.GetProjectSite(ref projectSiteGuid) as CSharpProjectShim;
// We should have gotten a ProjectSite back. If we didn't, that means we're being given
// a project site that we didn't get BindToProject called on first which is a no-no by
......
......@@ -27,7 +27,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.ProjectSystemShim
/// effectively methods that just QI from one interface to another), are implemented here.
/// </remarks>
[ExcludeFromCodeCoverage]
internal abstract partial class CSharpProjectShim : CSharpProject
internal abstract partial class CSharpProjectShim : AbstractEncProject
{
/// <summary>
/// This member is used to store a raw array of warning numbers, which is needed to properly implement
......@@ -56,6 +56,7 @@ internal abstract partial class CSharpProjectShim : CSharpProject
reportExternalErrorCreatorOpt,
projectSystemName,
hierarchy,
LanguageNames.CSharp,
serviceProvider,
miscellaneousFilesWorkspaceOpt,
visualStudioWorkspaceOpt,
......@@ -63,14 +64,25 @@ internal abstract partial class CSharpProjectShim : CSharpProject
{
_projectRoot = projectRoot;
_warningNumberArrayPointer = Marshal.AllocHGlobal(0);
InitializeOptions();
projectTracker.AddProject(this);
}
protected override void InitializeOptions()
private void InitializeOptions()
{
// Ensure the default options are set up
ResetAllOptions();
base.InitializeOptions();
this.SetOptions(this.CreateCompilationOptions(), this.CreateParseOptions());
}
protected override void UpdateAnalyzerRules()
{
base.UpdateAnalyzerRules();
this.SetOptions(this.CreateCompilationOptions(), this.CreateParseOptions());
}
public override void Disconnect()
......@@ -85,7 +97,7 @@ private string GetIdForErrorCode(int errorCode)
return "CS" + errorCode.ToString("0000");
}
protected override CSharpCompilationOptions CreateCompilationOptions()
protected CSharpCompilationOptions CreateCompilationOptions()
{
IDictionary<string, ReportDiagnostic> ruleSetSpecificDiagnosticOptions = null;
......@@ -275,7 +287,7 @@ private string GetStringOption(CompilerOptions optionID, string defaultValue)
}
}
protected override CSharpParseOptions CreateParseOptions()
protected CSharpParseOptions CreateParseOptions()
{
var symbols = GetStringOption(CompilerOptions.OPTID_CCSYMBOLS, defaultValue: "").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册