Skip to content

Commit

Permalink
Some missing locks
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Guerra committed Apr 9, 2018
1 parent 7e62a4f commit 1c789fa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
27 changes: 17 additions & 10 deletions src/CommonProviderImplementation/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ type DisposableTypeProviderForNamespaces(config, ?assemblyReplacementMap) as x =

do idCount <- idCount + 1

let dispose typeNameOpt = lock disposeActions <| fun () ->
for i = disposeActions.Count-1 downto 0 do
let disposeAction = disposeActions.[i]
let discard = disposeAction typeNameOpt
if discard then
disposeActions.RemoveAt(i)
let dispose typeNameOpt =
lock disposeActions <| fun () ->
for i = disposeActions.Count-1 downto 0 do
let disposeAction = disposeActions.[i]
let discard = disposeAction typeNameOpt
if discard then
disposeActions.RemoveAt(i)

do
log (sprintf "Creating TypeProviderForNamespaces %O [%d]" x id)
Expand All @@ -97,12 +98,14 @@ type DisposableTypeProviderForNamespaces(config, ?assemblyReplacementMap) as x =
member __.Id = id

member __.SetFileToWatch(fullTypeName, path) =
filesToWatch.Add(fullTypeName, path)
lock filesToWatch <| fun () ->
filesToWatch.Add(fullTypeName, path)

member __.GetFileToWath(fullTypeName) =
match filesToWatch.TryGetValue(fullTypeName) with
| true, path -> Some path
| _ -> None
lock filesToWatch <| fun () ->
match filesToWatch.TryGetValue(fullTypeName) with
| true, path -> Some path
| _ -> None

member __.AddDisposeAction action =
lock disposeActions <| fun () -> disposeActions.Add action
Expand Down Expand Up @@ -315,6 +318,10 @@ module internal ProviderHelpers =
| Some typeNameBeingDisposed when fullTypeName = typeNameBeingDisposed ->
providedTypesCache.Remove(fullTypeName)
log (sprintf "Dropping dispose action for %s [%d]" fullTypeName tp.Id)
// for the case where a file used by two TPs, when the file changes
// there will be two invalidations: A and B
// when the dispose action is called with A, A is removed from the cache
// so we need to remove the dispose action so it will won't be added when disposed is called with B
true
| _ ->
log (sprintf "Caching %s [%d] for 10 seconds" fullTypeName tp.Id)
Expand Down
12 changes: 6 additions & 6 deletions src/FSharp.Data.DesignTime/FSharp.Data.DesignTime.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
<!-- We place BOTH the design-time DLLs in well-known locations with resepct to the runtime DLL -->
<!-- This enables any runtime DLL to be used with any host tooling running in either netcoreapp2.0+ or net461+ -->
<Target Name="AfterBuild">
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.dll" DestinationFolder="..\..\bin\typeproviders\fsharp41\$(TargetFramework)" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.pdb" DestinationFolder="..\..\bin\typeproviders\fsharp41\$(TargetFramework)" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.dll" DestinationFolder="..\..\bin\typeproviders\fsharp41\$(TargetFramework)" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.pdb" DestinationFolder="..\..\bin\typeproviders\fsharp41\$(TargetFramework)" />
<!-- For legacy compat (to load into pre VS2017 15.6+ or FCS 20.x.x+ tooling) we place a copy of the .NET 4.x TPDTC DLL alongside the TPRTC DLL -->
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.dll" DestinationFolder="..\..\bin\lib\net45" Condition="'$(TargetFramework)' == 'net45'" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.pdb" DestinationFolder="..\..\bin\lib\net45" Condition="'$(TargetFramework)' == 'net45'" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.dll" DestinationFolder="..\..\bin\lib\netstandard2.0" Condition="'$(TargetFramework)' == 'net45'" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.pdb" DestinationFolder="..\..\bin\lib\netstandard2.0" Condition="'$(TargetFramework)' == 'net45'" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.dll" DestinationFolder="..\..\bin\lib\net45" Condition="'$(TargetFramework)' == 'net45'" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.pdb" DestinationFolder="..\..\bin\lib\net45" Condition="'$(TargetFramework)' == 'net45'" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.dll" DestinationFolder="..\..\bin\lib\netstandard2.0" Condition="'$(TargetFramework)' == 'net45'" />
<Copy SourceFiles="..\FSharp.Data.DesignTime\bin\$(Configuration)\$(TargetFramework)\FSharp.Data.DesignTime.pdb" DestinationFolder="..\..\bin\lib\netstandard2.0" Condition="'$(TargetFramework)' == 'net45'" />
</Target>
<Import Project="..\..\.paket\Paket.Restore.targets" />
</Project>
6 changes: 3 additions & 3 deletions src/FSharp.Data/FSharp.Data.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
<!-- We place BOTH the design-time DLLs in well-known locations with resepct to the runtime DLL -->
<!-- This enables any runtime DLL to be used with any host tooling running in either netcoreapp2.0+ or net461+ -->
<Target Name="AfterBuild">
<Copy SourceFiles="$(OutputPath)\FSharp.Data.dll" DestinationFolder="..\..\bin\lib\$(TargetFramework)" />
<Copy SourceFiles="$(OutputPath)\FSharp.Data.pdb" DestinationFolder="..\..\bin\lib\$(TargetFramework)" />
<Copy SourceFiles="$(OutputPath)\FSharp.Data.xml" DestinationFolder="..\..\bin\lib\$(TargetFramework)" />
<Copy SourceFiles="$(OutputPath)\FSharp.Data.dll" DestinationFolder="..\..\bin\lib\$(TargetFramework)" />
<Copy SourceFiles="$(OutputPath)\FSharp.Data.pdb" DestinationFolder="..\..\bin\lib\$(TargetFramework)" />
<Copy SourceFiles="$(OutputPath)\FSharp.Data.xml" DestinationFolder="..\..\bin\lib\$(TargetFramework)" />
</Target>

</Project>

0 comments on commit 1c789fa

Please sign in to comment.