-
Notifications
You must be signed in to change notification settings - Fork 844
Add Dump command to VS #4580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Dump command to VS #4580
Changes from all commits
d5a6a68
0e9ef10
b463580
d732bdf
0b2f885
0e7f77c
d2bfcfe
f8b75f0
b35ee40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. | ||
|
|
||
| namespace Microsoft.VisualStudio.FSharp.Editor | ||
|
|
||
| open System | ||
| open System.ComponentModel.Composition | ||
| open System.Diagnostics | ||
| open Microsoft.VisualStudio | ||
| open Microsoft.VisualStudio.Text.Editor | ||
| open Microsoft.VisualStudio.Utilities | ||
| open Microsoft.VisualStudio.Shell | ||
| open Microsoft.VisualStudio.Shell.Interop | ||
| open Microsoft.VisualStudio.FSharp.Interactive | ||
| open System.ComponentModel.Design | ||
| open Microsoft.Diagnostics.Runtime | ||
|
|
||
|
|
||
| [<Export(typeof<IWpfTextViewCreationListener>)>] | ||
| [<ContentType(FSharpConstants.FSharpContentTypeName)>] | ||
| [<TextViewRole(PredefinedTextViewRoles.PrimaryDocument)>] | ||
| type internal DumpCommandFilterProvider | ||
| [<ImportingConstructor>] | ||
| (checkerProvider: FSharpCheckerProvider, | ||
| [<Import(typeof<SVsServiceProvider>)>] serviceProvider: System.IServiceProvider) = | ||
|
|
||
| let projectSystemPackage = | ||
| lazy( | ||
| let shell = serviceProvider.GetService(typeof<SVsShell>) :?> IVsShell | ||
| let packageToBeLoadedGuid = ref (Guid "{91a04a73-4f2c-4e7c-ad38-c1a68e7da05c}") // FSharp ProjectSystem guid | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the constant defined |
||
| match shell.LoadPackage packageToBeLoadedGuid with | ||
| | VSConstants.S_OK, pkg -> | ||
| pkg :?> Package | ||
| | _ -> null) | ||
|
|
||
| let FSharpDump (_this:Package) (_sender:obj) (_e:EventArgs) = | ||
| checkerProvider.Checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() | ||
| use target = DataTarget.CreateSnapshotAndAttach(Process.GetCurrentProcess().Id) | ||
| let runtime = target.ClrVersions.[0].CreateRuntime(); | ||
| let outputPane = projectSystemPackage.Value.GetOutputPane(VSConstants.OutputWindowPaneGuid.BuildOutputPane_guid, "FSharp Dump") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with this API. Does "FSharp Dump" need to be localized/translated? If so it'll have to be added to a |
||
| runtime.Heap.EnumerateObjects() | ||
| |> Seq.groupBy (fun x -> x.Type.Name) | ||
| |> Seq.map (fun (ty, os) -> ty, os |> Seq.sumBy (fun x -> x.Size), os |> Seq.length) | ||
| |> Seq.sortBy (fun (_, size, _) -> -int64 size) | ||
| |> Seq.take 100 | ||
| |> Seq.iter (fun (ty, size, count) -> outputPane.OutputString (sprintf "Type: %s, Total size: %d, Instance count: %d\r\n" ty size count) |> ignore) | ||
|
|
||
| interface IWpfTextViewCreationListener with | ||
| member __.TextViewCreated(_textView) = | ||
| let commandService = (projectSystemPackage.Value :> System.IServiceProvider).GetService(typeof<IMenuCommandService>) :?> OleMenuCommandService | ||
| let id = new CommandID(Guids.guidFSharpProjectCmdSet,int32 Guids.cmdIDFSharpDump) | ||
| let cmd = new MenuCommand(new EventHandler(FSharpDump projectSystemPackage.Value), id) | ||
| commandService.AddCommand(cmd) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,7 @@ | |
| <Compile Include="Structure\BlockStructureService.fs" /> | ||
| <Compile Include="Commands\HelpContextService.fs" /> | ||
| <Compile Include="Commands\FsiCommandService.fs" /> | ||
| <Compile Include="Commands\DumpCommandService.fs" /> | ||
| <Compile Include="Commands\XmlDocCommandService.fs" /> | ||
| <Compile Include="CodeFix\AddNewKeywordToDisposableConstructorInvocation.fs" /> | ||
| <Compile Include="CodeFix\AddOpenCodeFixProvider.fs" /> | ||
|
|
@@ -106,6 +107,7 @@ | |
| <Reference Include="PresentationFramework" /> | ||
| <Reference Include="System" /> | ||
| <Reference Include="System.ComponentModel.Composition" /> | ||
| <Reference Include="System.Design" /> | ||
| <Reference Include="System.Drawing" /> | ||
| <Reference Include="System.Windows.Forms" /> | ||
| <Reference Include="System.Xaml" /> | ||
|
|
@@ -139,6 +141,7 @@ | |
| <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" /> | ||
| <PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutablePackageVersion)" /> | ||
| <PackageReference Include="VSSDK.VSLangProj" Version="$(VSSDKVSLangProjPackageVersion)" /> | ||
| <PackageReference Include="Microsoft.Diagnostics.Runtime" Version="0.9.180305.1" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,6 +133,15 @@ | |
| <ButtonText>F# Interactive</ButtonText> | ||
| </Strings> | ||
| </Button> | ||
|
|
||
| <Button guid="FSharpProjectCmdSet" id="cmdidFsDump" priority="0x8000" type="Button"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This addition should have (but obviously didn't) update all of the msbuild vsintegration\src\FSharp.ProjectSystem.FSharp\ProjectSystem.fsproj /t:UpxateXlf |
||
| <!-- low priority --> | ||
| <Parent guid="guidSHLMainMenu" id="IDG_VS_WNDO_OTRWNDWS1"/> | ||
| <Strings> | ||
| <CommandName>FSharp.Dump</CommandName> | ||
| <ButtonText>F# Dump</ButtonText> | ||
| </Strings> | ||
| </Button> | ||
|
|
||
| <!-- In Dev11+, shell now has | ||
| <Button guid ="guidVSStd11" id ="cmdidInteractiveSessionInterrupt" priority ="0x100" type ="Button"> | ||
|
|
@@ -420,6 +429,8 @@ | |
| <IDSymbol name = "FSharpSendThisReferenceToInteractiveCmd" value ="0x5004"/> | ||
| <IDSymbol name = "FSharpSendReferencesToInteractiveCmd" value ="0x5005"/> | ||
| <IDSymbol name = "FSharpSendProjectOutputToInteractiveCmd" value ="0x5006"/> | ||
|
|
||
| <IDSymbol name="cmdidFsDump" value="0x0100" /> | ||
| </GuidSymbol> | ||
| <GuidSymbol name="FSharpMoveUpBmp" value="{6C2FAD07-753D-45ab-BEE9-5D12D207991B}" > | ||
| <IDSymbol name="moveUp" value="1" /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version number should be added to
build\targets\PackageVersions.propsunder theother packagesheading and placed in alphabetical order:And replaced in this file with
$(MicrosoftDiagnosticsRuntimePackageVersion).