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

Commit722a64a

Browse files
authored
Fix solution reload and config change issues (#3025)
* fix config change* Fix configuration changes* Fix colorization cache for changing defines* fix config switching* add manual test cases* Fix test* minor nit* use correct reference count* cleanup decrement logic* fix build* Update CompileOps.fs* adjust unit tests mocks* adjust unit tests mocks* fix test* add new misc project test* do ComputeSourcesAndFlags later* do ComputeSourcesAndFlags once* variations* keep dialog open
1 parent56a586d commit722a64a

File tree

57 files changed

+1300
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1300
-298
lines changed

‎fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type ProjectCracker =
3333

3434
logMap:= Map.add opts.ProjectFile opts.LogOutput!logMap
3535
{ ProjectFileName= opts.ProjectFile
36-
ProjectFileNames= sourceFiles
36+
SourceFiles= sourceFiles
3737
OtherOptions= otherOptions
3838
ReferencedProjects= referencedProjects
3939
IsIncompleteTypeCheckEnvironment=false

‎src/absil/ilread.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3967,7 +3967,7 @@ let OpenILModuleReader infile opts =
39673967

39683968
// ++GLOBAL MUTABLE STATE (concurrency safe via locking)
39693969
typeILModuleReaderCacheLockToken()=interface LockToken
3970-
letilModuleReaderCache=new AgedLookup<ILModuleReaderCacheLockToken,(string* System.DateTime* ILScopeRef* bool), ILModuleReader>(0,areSame=(fun(x,y)-> x= y))
3970+
letilModuleReaderCache=new AgedLookup<ILModuleReaderCacheLockToken,(string* System.DateTime* ILScopeRef* bool), ILModuleReader>(0,areSimilar=(fun(x,y)-> x= y))
39713971
letilModuleReaderCacheLock= Lock()
39723972

39733973
letOpenILModuleReaderAfterReadingAllBytes infile opts=

‎src/fsharp/CompileOps.fs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,13 +2701,15 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
27012701
match fslibExplicitFilenameOptwith
27022702
| Some(fslibFilename)->
27032703
letfilename= ComputeMakePathAbsolute data.implicitIncludeDir fslibFilename
2704-
try
2705-
use ilReader= OpenILBinary(filename,data.optimizeForMemory,data.openBinariesInMemory,None,None, data.shadowCopyReferences)
2706-
checkFSharpBinaryCompatWithMscorlib filename ilReader.ILAssemblyRefs ilReader.ILModuleDef.ManifestOfAssembly.Version rangeStartup;
2707-
letfslibRoot= Path.GetDirectoryName(FileSystem.GetFullPathShim(filename))
2708-
fslibRoot(* , sprintf "v%d.%d" v1 v2*)
2709-
with e->
2710-
error(Error(FSComp.SR.buildErrorOpeningBinaryFile(filename, e.Message), rangeStartup))
2704+
if fslibReference.ProjectReference.IsNonethen
2705+
try
2706+
use ilReader= OpenILBinary(filename,data.optimizeForMemory,data.openBinariesInMemory,None,None, data.shadowCopyReferences)
2707+
checkFSharpBinaryCompatWithMscorlib filename ilReader.ILAssemblyRefs ilReader.ILModuleDef.ManifestOfAssembly.Version rangeStartup;
2708+
with e->
2709+
error(Error(FSComp.SR.buildErrorOpeningBinaryFile(filename, e.Message), rangeStartup))
2710+
2711+
letfslibRoot= Path.GetDirectoryName(FileSystem.GetFullPathShim(filename))
2712+
fslibRoot
27112713
|_->
27122714
data.defaultFSharpBinariesDir
27132715
#endif

‎src/fsharp/InternalCollections.fs‎

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type internal ValueStrength<'T when 'T : not struct> =
1313
| WeakofWeakReference<'T>
1414
#endif
1515

16-
typeinternalAgedLookup<'Token,'Key,'Valuewhen'Value:notstruct>(keepStrongly:int,areSame,?requiredToKeep,?onStrongDiscard,?keepMax: int)=
16+
typeinternalAgedLookup<'Token,'Key,'Valuewhen'Value:notstruct>(keepStrongly:int,areSimilar,?requiredToKeep,?onStrongDiscard,?keepMax: int)=
1717
/// The list of items stored. Youngest is at the end of the list.
1818
/// The choice of order is somewhat arbitrary. If the other way then adding
1919
/// items would be O(1) and removing O(N).
@@ -39,8 +39,8 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro
3939
// This function returns true if two keys are the same according to the predicate
4040
// function passed in.
4141
|[]->None
42-
|(key',value)::t->
43-
ifareSame(key,key')then Some(key',value)
42+
|(similarKey,value)::t->
43+
ifareSimilar(key,similarKey)then Some(similarKey,value)
4444
else Lookup key t
4545
Lookup key data
4646

@@ -53,18 +53,18 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro
5353

5454
/// Promote a particular key value.
5555
letPromote(data,key,value)=
56-
(data|> List.filter(fun(key',_)->not(areSame(key,key'))))@[(key, value)]
56+
(data|> List.filter(fun(similarKey,_)->not(areSimilar(key,similarKey))))@[(key, value)]
5757

5858
/// Remove a particular key value.
5959
letRemoveImpl(data,key)=
60-
letdiscard,keep= data|> List.partition(fun(key',_)->areSame(key,key'))
60+
letdiscard,keep= data|> List.partition(fun(similarKey,_)->areSimilar(key,similarKey))
6161
keep, discard
6262

6363
letTryGetKeyValueImpl(data,key)=
6464
match TryPeekKeyValueImpl(data,key)with
65-
| Some(key', value)as result->
65+
| Some(similarKey, value)as result->
6666
// If the result existed, move it to the end of the list (more likely to keep it)
67-
result,Promote(data,key',value)
67+
result,Promote(data,similarKey,value)
6868
| None-> None,data
6969

7070
/// Remove weak entries from the list that have been collected.
@@ -154,37 +154,42 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro
154154

155155

156156

157-
typeinternalMruCache<'Token,'Key,'Valuewhen'Value:notstruct>(keepStrongly,areSame,?isStillValid: 'Key*'Value->bool,?areSameForSubsumption,?requiredToKeep,?onStrongDiscard,?keepMax)=
157+
typeinternalMruCache<'Token,'Key,'Valuewhen'Value:notstruct>(keepStrongly,areSame,?isStillValid: 'Key*'Value->bool,?areSimilar,?requiredToKeep,?onStrongDiscard,?keepMax)=
158158

159-
/// Default behavior of <c>areSameForSubsumption</c> function is areSame.
160-
letareSameForSubsumption= defaultArgareSameForSubsumption areSame
159+
/// Default behavior of <c>areSimilar</c> function is areSame.
160+
letareSimilar= defaultArgareSimilar areSame
161161

162162
/// The list of items in the cache. Youngest is at the end of the list.
163163
/// The choice of order is somewhat arbitrary. If the other way then adding
164164
/// items would be O(1) and removing O(N).
165-
letcache= AgedLookup<'Token, 'Key,'Value>(keepStrongly=keepStrongly,areSame=areSameForSubsumption,?onStrongDiscard=onStrongDiscard,?keepMax=keepMax,?requiredToKeep=requiredToKeep)
165+
letcache= AgedLookup<'Token, 'Key,'Value>(keepStrongly=keepStrongly,areSimilar=areSimilar,?onStrongDiscard=onStrongDiscard,?keepMax=keepMax,?requiredToKeep=requiredToKeep)
166166

167167
/// Whether or not this result value is still valid.
168168
letisStillValid= defaultArg isStillValid(fun _->true)
169169

170+
memberbc.ContainsSimilarKey(tok,key)=
171+
match cache.TryPeekKeyValue(tok, key)with
172+
| Some(_similarKey,_value)->true
173+
| None->false
174+
170175
memberbc.TryGetAny(tok,key)=
171176
match cache.TryPeekKeyValue(tok, key)with
172-
| Some(key', value)->
173-
if areSame(key',key)then Some(value)
177+
| Some(similarKey, value)->
178+
if areSame(similarKey,key)then Some(value)
174179
else None
175180
| None-> None
176181

177182
memberbc.TryGet(tok,key)=
178183
match cache.TryGetKeyValue(tok, key)with
179-
| Some(key', value)->
180-
if areSame(key', key)&& isStillValid(key,value)then Some value
184+
| Some(similarKey, value)->
185+
if areSame(similarKey, key)&& isStillValid(key,value)then Some value
181186
else None
182187
| None-> None
183188

184189
memberbc.Set(tok,key:'Key,value:'Value)=
185190
cache.Put(tok, key,value)
186191

187-
memberbc.Remove(tok,key)=
192+
memberbc.RemoveAnySimilar(tok,key)=
188193
cache.Remove(tok, key)
189194

190195
memberbc.Clear(tok)=

‎src/fsharp/InternalCollections.fsi‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ namespace Internal.Utilities.Collections
44

55
/// Simple aging lookup table. When a member is accessed it's
66
/// moved to the top of the list and when there are too many elements
7-
/// the least-recently-accessed element falls of the end.
7+
/// the least-recently-accessed element falls of the end.
8+
///
9+
/// - areSimilar: Keep at most once association for two similar keys (as given by areSimilar)
810
typeinternalAgedLookup<'Token,'Key,'Valuewhen'Value:notstruct>=
911
new: keepStrongly:int
10-
*areSame:('Key* 'Key-> bool)
12+
*areSimilar:('Key* 'Key-> bool)
1113
* ?requiredToKeep:('Value-> bool)
1214
* ?onStrongDiscard:('Value-> unit)// this may only be set if keepTotal=keepStrongly, i.e. not weak entries
1315
* ?keepMax: int
@@ -40,25 +42,36 @@ namespace Internal.Utilities.Collections
4042
/// threads seeing different live sets of cached items, and may result in the onDiscard action
4143
/// being called multiple times. In practice this means the collection is only safe for concurrent
4244
/// access if there is no discard action to execute.
45+
///
46+
///- areSimilar: Keep at most once association for two similar keys(as given by areSimilar)
4347
type internal MruCache<'Token, 'Key,'Value when 'Value: not struct>=
4448
new: keepStrongly:int
4549
* areSame:('Key* 'Key-> bool)
4650
* ?isStillValid:('Key* 'Value-> bool)
47-
* ?areSameForSubsumption:('Key* 'Key-> bool)
51+
* ?areSimilar:('Key* 'Key-> bool)
4852
* ?requiredToKeep:('Value-> bool)
4953
* ?onDiscard:('Value-> unit)
5054
* ?keepMax:int
5155
-> MruCache<'Token,'Key,'Value>
56+
5257
/// Clear out the cache.
5358
memberClear:'Token->unit
54-
/// Get the value for the given key or <c>None</c> if not already available.
59+
60+
/// Get the similar (subsumable) value for the given key or <c>None</c> if not already available.
61+
memberContainsSimilarKey:'Token* key:'Key-> bool
62+
63+
/// Get the value for the given key or<c>None</c> if not still valid.
5564
member TryGetAny: 'Token* key:'Key-> 'Value option
56-
/// Get the value for the given key or None if not already available
65+
66+
/// Get the value for the given key or None, but only if entry is still valid
5767
member TryGet: 'Token* key:'Key-> 'Value option
68+
5869
/// Remove the given value from the mru cache.
59-
member Remove: 'Token* key:'Key-> unit
70+
member RemoveAnySimilar: 'Token* key:'Key-> unit
71+
6072
/// Set the given key.
6173
member Set: 'Token* key:'Key* value:'Value-> unit
74+
6275
/// Resize
6376
member Resize: 'Token* keepStrongly: int* ?keepMax: int-> unit
6477

‎src/fsharp/vs/IncrementalBuild.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ type FrameworkImportsCacheKey = (*resolvedpath*)string list * string * (*TargetF
10371037
typeFrameworkImportsCache(keepStrongly)=
10381038

10391039
// Mutable collection protected via CompilationThreadToken
1040-
letframeworkTcImportsCache= AgedLookup<CompilationThreadToken, FrameworkImportsCacheKey,(TcGlobals* TcImports)>(keepStrongly,areSame=(fun(x,y)-> x= y))
1040+
letframeworkTcImportsCache= AgedLookup<CompilationThreadToken, FrameworkImportsCacheKey,(TcGlobals* TcImports)>(keepStrongly,areSimilar=(fun(x,y)-> x= y))
10411041

10421042
member__.Downsize(ctok)= frameworkTcImportsCache.Resize(ctok, keepStrongly=0)
10431043
member__.Clear(ctok)= frameworkTcImportsCache.Clear(ctok)
@@ -1562,7 +1562,7 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs
15621562
returntrue
15631563
}
15641564

1565-
memberbuilder.GetCheckResultsBeforeFileInProjectIfReady(filename):PartialCheckResults option=
1565+
memberbuilder.GetCheckResultsBeforeFileInProjectEvenIfStale(filename):PartialCheckResults option=
15661566
letslotOfFile= builder.GetSlotOfFileName filename
15671567
letresult=
15681568
match slotOfFilewith
@@ -1676,7 +1676,7 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs
16761676
#endif
16771677
}
16781678

1679-
member__.ProjectFileNames= sourceFiles|> List.map(fun(_,f,_)-> f)
1679+
member__.SourceFiles= sourceFiles|> List.map(fun(_,f,_)-> f)
16801680

16811681
/// CreateIncrementalBuilder (for background type checking). Note that fsc.fs also
16821682
/// creates an incremental builder used by the command line compiler.

‎src/fsharp/vs/IncrementalBuild.fsi‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,14 @@ type internal PartialCheckResults =
6565
[<Class>]
6666
typeinternalIncrementalBuilder=
6767

68-
/// Increment the usage count on the IncrementalBuilder by 1. This initial usage count is 0. The returns an IDisposable which will
69-
/// decrement the usage count on the entire build by 1 and dispose if it is no longer used by anyone.
70-
memberIncrementUsageCount:unit->IDisposable
71-
7268
/// Check if the builder is not disposed
7369
memberIsAlive:bool
7470

7571
/// The TcConfig passed in to the builder creation.
7672
memberTcConfig:TcConfig
7773

7874
/// The full set of source files including those from options
79-
memberProjectFileNames:string list
75+
memberSourceFiles:string list
8076

8177
/// Raised just before a file is type-checked, to invalidate the state of the file in VS and force VS to request a new direct typecheck of the file.
8278
/// The incremental builder also typechecks the file (error and intellisense results from the background builder are not
@@ -110,7 +106,7 @@ type internal IncrementalBuilder =
110106
/// This is a very quick operation.
111107
///
112108
/// This is safe for use from non-compiler threads but the objects returned must in many cases be accessed only from the compiler thread.
113-
memberGetCheckResultsBeforeFileInProjectIfReady:filename:string->PartialCheckResults option
109+
memberGetCheckResultsBeforeFileInProjectEvenIfStale:filename:string->PartialCheckResults option
114110

115111
/// Get the preceding typecheck state of a slot, but only if it is up-to-date w.r.t.
116112
/// the timestamps on files and referenced DLLs prior to this one. Return None if the result is not available.
@@ -153,7 +149,11 @@ type internal IncrementalBuilder =
153149

154150
static member TryCreateBackgroundBuilderForProjectOptions: CompilationThreadToken* ReferenceResolver.Resolver* defaultFSharpBinariesDir: string* FrameworkImportsCache* scriptClosureOptions:LoadClosure option* sourceFiles:string list* commandLineArgs:string list* projectReferences: IProjectReference list* projectDirectory:string* useScriptResolutionRules:bool* keepAssemblyContents: bool* keepAllBackgroundResolutions: bool* maxTimeShareMilliseconds: int64-> Cancellable<IncrementalBuilder option* FSharpErrorInfo list>
155151

152+
/// Increment the usage count on the IncrementalBuilder by 1. This initial usage count is 0 so immediately after creation
153+
/// a call to KeepBuilderAlive should be made. The returns an IDisposable which will
154+
/// decrement the usage count and dispose if the usage count goes to zero
156155
static member KeepBuilderAlive: IncrementalBuilder option-> IDisposable
156+
157157
member IsBeingKeptAliveApartFromCacheEntry: bool
158158

159159
/// Generalized Incremental Builder. This is exposed only for unittesting purposes.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp