Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee56e58

Browse files
TIHanbrettfo
authored andcommitted
Using ProjectId for project options
1 parenta08481c commitee56e58

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

‎vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs‎

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ type private CpsStamp = DateTime
2727
[<AutoOpen>]
2828
moduleprivateFSharpProjectOptionsHelpers=
2929

30-
letmapCpsProjectToSite(workspace:VisualStudioWorkspaceImpl,project:Project,serviceProvider:System.IServiceProvider,cpsCommandLineOptions:IDictionary<ProjectId,CpsStamp*string[]*string[]*string[]>)=
30+
letmapCpsProjectToSite(workspace:VisualStudioWorkspaceImpl,project:Project,serviceProvider:System.IServiceProvider,cpsCommandLineOptions:IDictionary<ProjectId,CpsStamp*string[]*string[]>)=
3131
lethier= workspace.GetHierarchy(project.Id)
3232
letcpsStampOpt,sourcePaths,referencePaths,options=
3333
match cpsCommandLineOptions.TryGetValue(project.Id)with
34-
|true,(cpsStamp, sourcePaths,referencePaths,options)-> Some(cpsStamp), sourcePaths,referencePaths, options
34+
|true,(cpsStamp, sourcePaths, options)-> Some(cpsStamp), sourcePaths,[||], options
3535
|false,_-> None,[||],[||],[||]
3636
cpsStampOpt,
3737
{
@@ -94,7 +94,7 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
9494
letcancellationTokenSource=new CancellationTokenSource()
9595

9696
// Hack to store command line options from HandleCommandLineChanges
97-
letcpsCommandLineOptions=new ConcurrentDictionary<ProjectId, DateTime* string[]* string[]* string[]>()
97+
letcpsCommandLineOptions=new ConcurrentDictionary<ProjectId, DateTime* string[]* string[]>()
9898

9999
letcache= Dictionary<ProjectId, CpsStamp option* VersionStamp* FSharpParsingOptions* FSharpProjectOptions>()
100100

@@ -142,20 +142,36 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
142142
letcpsStampOpt,provideSite= mapCpsProjectToSite(workspace, project, serviceProvider, cpsCommandLineOptions)
143143
cpsStampOpt, provideSite.GetProjectSite()
144144

145+
letotherOptions=
146+
project.ProjectReferences
147+
|> Seq.map(fun x->"-r:"+ project.Solution.GetProject(x.ProjectId).OutputFilePath)
148+
|> Array.ofSeq
149+
|> Array.append(
150+
project.MetadataReferences.OfType<VisualStudioMetadataReference.Snapshot>()
151+
|> Seq.map(fun x->"-r:"+ x.FilePath)
152+
|> Array.ofSeq
153+
|> Array.append(
154+
// Clear any references from CompilationOptions.
155+
// We get the references from Project.ProjectReferences/Project.MetadataReferences.
156+
projectSite.CompilationOptions
157+
|> Array.filter(fun x->not(x.Contains("-r:")))
158+
)
159+
)
160+
145161
letprojectOptions=
146162
{
147163
ProjectFileName= projectSite.ProjectFileName
148-
ProjectId=None
164+
ProjectId=Some(projectId.ToFSharpProjectIdString())
149165
SourceFiles= projectSite.CompilationSourceFiles
150-
OtherOptions=projectSite.CompilationOptions
166+
OtherOptions=otherOptions
151167
ReferencedProjects= referencedProjects
152168
IsIncompleteTypeCheckEnvironment= projectSite.IsIncompleteTypeCheckEnvironment
153169
UseScriptResolutionRules= SourceFile.MustBeSingleFileProject(Path.GetFileName(project.FilePath))
154170
LoadTime= projectSite.LoadTime
155171
UnresolvedReferences= None
156172
OriginalLoadReferences=[]
157173
ExtraProjectInfo= None
158-
Stamp= Some(int64<|projectStamp.GetHashCode())
174+
Stamp= Some(int64(projectStamp.GetHashCode()))
159175
}
160176

161177
// This can happen if we didn't receive the callback from HandleCommandLineChanges yet.
@@ -173,7 +189,7 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
173189
|true,(cpsStampOpt, projectStamp2, parsingOptions, projectOptions)->
174190
letcpsStampOpt2=
175191
match cpsCommandLineOptions.TryGetValue(projectId)with
176-
|true,(cpsStampOpt2,_,_,_)-> Some(cpsStampOpt2)
192+
|true,(cpsStampOpt2,_,_)-> Some(cpsStampOpt2)
177193
|_-> None
178194
if projectStamp<> projectStamp2|| cpsStampOpt<> cpsStampOpt2then
179195
cache.Remove(projectId)|> ignore
@@ -203,8 +219,8 @@ type private FSharpProjectOptionsReactor (workspace: VisualStudioWorkspaceImpl,
203219
member__.ClearOptionsByProjectId(projectId)=
204220
agent.Post(FSharpProjectOptionsMessage.ClearOptions(projectId))
205221

206-
member__.SetCpsCommandLineOptions(projectId,stamp,sourcePaths,referencePaths,options)=
207-
cpsCommandLineOptions.[projectId]<-(stamp, sourcePaths,referencePaths,options)
222+
member__.SetCpsCommandLineOptions(projectId,stamp,sourcePaths,options)=
223+
cpsCommandLineOptions.[projectId]<-(stamp, sourcePaths, options)
208224

209225
member__.TryGetCachedOptionsByProjectId(projectId)=
210226
match cache.TryGetValue(projectId)with
@@ -340,7 +356,7 @@ type internal FSharpProjectOptionsManager
340356
/// This handles commandline change notifications from the Dotnet Project-system
341357
/// Prior to VS 15.7 path contained path to project file, post 15.7 contains target binpath
342358
/// binpath is more accurate because a project file can have multiple in memory projects based on configuration
343-
member__.HandleCommandLineChanges(path:string,sources:ImmutableArray<CommandLineSourceFile>,references:ImmutableArray<CommandLineReference>,options:ImmutableArray<string>)=
359+
member__.HandleCommandLineChanges(path:string,sources:ImmutableArray<CommandLineSourceFile>,_references:ImmutableArray<CommandLineReference>,options:ImmutableArray<string>)=
344360
use _logBlock= Logger.LogBlock(LogEditorFunctionId.LanguageService_HandleCommandLineArgs)
345361

346362
letprojectId=
@@ -353,8 +369,7 @@ type internal FSharpProjectOptionsManager
353369
if Path.IsPathRooted(p)|| path=nullthen p
354370
else Path.Combine(Path.GetDirectoryName(path), p)
355371
letsourcePaths= sources|> Seq.map(fun s-> fullPath s.Path)|> Seq.toArray
356-
letreferencePaths= references|> Seq.map(fun r-> fullPath r.Reference)|> Seq.toArray
357372

358-
reactor.SetCpsCommandLineOptions(projectId, DateTime.UtcNow, sourcePaths,referencePaths,options.ToArray())
373+
reactor.SetCpsCommandLineOptions(projectId, DateTime.UtcNow, sourcePaths, options.ToArray())
359374

360375
member__.Checker= checkerProvider.Checker

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp