Skip to content

Commit 1131b00

Browse files
committed
Add CopilotTokenTrackerRunner project with initial Program.cs
- Created a new project file for CopilotTokenTrackerRunner targeting .NET Framework 4.7.2. - Added Program.cs to provide a simple entry point and instructions for running the CopilotTokenTracker extension in a Visual Studio experimental instance.
1 parent b7060e1 commit 1131b00

File tree

55 files changed

+133032
-284
lines changed

Some content is hidden

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

55 files changed

+133032
-284
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ log-example.txt
1414
visualstudio-extension/**/obj/
1515
visualstudio-extension/**/bin/
1616
visualstudio-extension/.vs/
17+
visualstudio-extension/**/obj/**
18+
visualstudio-extension/**/bin/**
1719

1820
# Accidental nested Visual Studio extension workspace/build output
1921
visualstudio-extension/visualstudio-extension/
22+
visualstudio-extension/src/CopilotTokenTracker/bin/Release/net472/MessagePack.Annotations.dll
23+
visualstudio-extension/src/CopilotTokenTracker/bin/Release/net472/System.Buffers.dll

visualstudio-extension/msbuild-preprocess.txt

Lines changed: 21232 additions & 0 deletions
Large diffs are not rendered by default.

visualstudio-extension/src/CopilotTokenTracker/CopilotTokenTracker.csproj

Lines changed: 107 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,92 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
<RuntimeIdentifiers>win;win-x86;win-x64;win-arm;win-arm64</RuntimeIdentifiers>
7+
</PropertyGroup>
8+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
39
<PropertyGroup>
10+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
11+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
12+
<SchemaVersion>2.0</SchemaVersion>
13+
<ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<ProjectGuid>{A1B2C3D4-E5F6-A7B8-C9D0-E1F2A3B4C5D6}</ProjectGuid>
415
<OutputType>Library</OutputType>
5-
<TargetFramework>net472</TargetFramework>
6-
<UseWPF>true</UseWPF>
7-
<Nullable>enable</Nullable>
8-
<LangVersion>latest</LangVersion>
16+
<AppDesignerFolder>Properties</AppDesignerFolder>
917
<RootNamespace>CopilotTokenTracker</RootNamespace>
1018
<AssemblyName>CopilotTokenTracker</AssemblyName>
11-
<!-- Required for VS extension to locate the assembly from its install dir -->
19+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
20+
<LangVersion>latest</LangVersion>
21+
<Nullable>enable</Nullable>
22+
<GeneratePkgDefFile>true</GeneratePkgDefFile>
1223
<UseCodebase>true</UseCodebase>
13-
<!-- Suppress package reference warnings for VS SDK assemblies excluded from output -->
14-
<NoWarn>$(NoWarn);NU1701</NoWarn>
24+
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
25+
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer>
26+
<IncludeDebugSymbolsInLocalVSIXDeployment>false</IncludeDebugSymbolsInLocalVSIXDeployment>
27+
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
28+
<CopyOutputSymbolsToOutputDirectory>true</CopyOutputSymbolsToOutputDirectory>
29+
<StartAction>Program</StartAction>
30+
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram>
31+
<StartArguments>/rootsuffix Exp</StartArguments>
32+
</PropertyGroup>
33+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
34+
<DebugSymbols>true</DebugSymbols>
35+
<DebugType>full</DebugType>
36+
<Optimize>false</Optimize>
37+
<OutputPath>bin\Debug\</OutputPath>
38+
<DefineConstants>DEBUG;TRACE</DefineConstants>
39+
<ErrorReport>prompt</ErrorReport>
40+
<WarningLevel>4</WarningLevel>
41+
</PropertyGroup>
42+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43+
<DebugType>pdbonly</DebugType>
44+
<Optimize>true</Optimize>
45+
<OutputPath>bin\Release\</OutputPath>
46+
<DefineConstants>TRACE</DefineConstants>
47+
<ErrorReport>prompt</ErrorReport>
48+
<WarningLevel>4</WarningLevel>
1549
</PropertyGroup>
1650

51+
<!-- Source files -->
1752
<ItemGroup>
18-
<!-- Visual Studio SDK (excluded from runtime — VS provides these at host time) -->
19-
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.6.36389" ExcludeAssets="Runtime" />
20-
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.6.2164" PrivateAssets="all" />
21-
<!-- Embedded Chromium for the WebView2 tool window -->
22-
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2478.35" />
23-
<!-- MessagePack for parsing VS Copilot Chat binary session files -->
24-
<PackageReference Include="MessagePack" Version="2.5.187" />
25-
<!-- JSON serialisation for the data bridge to the webview -->
26-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
27-
<!-- System.Text.Json is not built into net472; pull it via NuGet -->
28-
<PackageReference Include="System.Text.Json" Version="8.0.5" />
53+
<Compile Include="CopilotTokenTrackerPackage.cs" />
54+
<Compile Include="Commands\ShowTokenTrackerCommand.cs" />
55+
<Compile Include="Data\Models.cs" />
56+
<Compile Include="Data\SessionDiscovery.cs" />
57+
<Compile Include="Data\SessionParser.cs" />
58+
<Compile Include="Data\StatsBuilder.cs" />
59+
<Compile Include="Data\TokenEstimator.cs" />
60+
<Compile Include="Properties\Settings.Designer.cs">
61+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
62+
<AutoGen>True</AutoGen>
63+
<DependentUpon>Settings.settings</DependentUpon>
64+
</Compile>
65+
<Compile Include="ToolWindow\TokenTrackerToolWindow.cs" />
66+
<Compile Include="WebBridge\ThemedHtmlBuilder.cs" />
67+
<Compile Include="Properties\AssemblyInfo.cs" />
2968
</ItemGroup>
3069

31-
<!-- Framework assemblies needed for OleMenuCommandService / MenuCommand -->
70+
<!-- WPF XAML -->
3271
<ItemGroup>
33-
<Reference Include="System.Design" />
72+
<Page Include="ToolWindow\TokenTrackerControl.xaml">
73+
<Generator>MSBuild:Compile</Generator>
74+
<SubType>Designer</SubType>
75+
</Page>
76+
<Compile Include="ToolWindow\TokenTrackerControl.xaml.cs">
77+
<DependentUpon>TokenTrackerControl.xaml</DependentUpon>
78+
</Compile>
79+
</ItemGroup>
80+
81+
<!-- VSIX manifest -->
82+
<ItemGroup>
83+
<None Include="Properties\Settings.settings">
84+
<Generator>SettingsSingleFileGenerator</Generator>
85+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
86+
</None>
87+
<None Include="source.extension.vsixmanifest">
88+
<SubType>Designer</SubType>
89+
</None>
3490
</ItemGroup>
3591

3692
<!-- VSCT: VS Command Table definition (menus / commands) -->
@@ -40,38 +96,50 @@
4096
</VSCTCompile>
4197
</ItemGroup>
4298

43-
<!-- VSIX manifest -->
99+
<!-- Embedded resources -->
44100
<ItemGroup>
45-
<Content Include="source.extension.vsixmanifest">
46-
<SubType>Designer</SubType>
47-
</Content>
101+
<EmbeddedResource Include="WebBridge\vscode-shim.js" />
48102
</ItemGroup>
49103

50-
<!-- vscode-shim.js embedded as a resource so it can be injected into WebView2 pages -->
104+
<!-- Framework references -->
51105
<ItemGroup>
52-
<EmbeddedResource Include="WebBridge\vscode-shim.js" />
106+
<Reference Include="System" />
107+
<Reference Include="System.Design" />
108+
<Reference Include="System.Drawing" />
109+
<Reference Include="PresentationCore" />
110+
<Reference Include="PresentationFramework" />
111+
<Reference Include="WindowsBase" />
112+
<Reference Include="System.Xaml" />
53113
</ItemGroup>
54114

115+
<!-- NuGet packages -->
116+
<ItemGroup>
117+
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.6.36389" ExcludeAssets="runtime" NoWarn="NU1604" />
118+
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.6.2164" NoWarn="NU1604" />
119+
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2478.35" />
120+
<PackageReference Include="MessagePack" Version="2.5.187" />
121+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
122+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
123+
</ItemGroup>
124+
125+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
126+
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
127+
55128
<!--
56129
Copy webview JS bundles from the vscode-extension build output into this project's
57130
webview\ folder so they can be packaged inside the VSIX.
58131
Prerequisite: run `npm run compile` in vscode-extension/ first.
59132
-->
60133
<Target Name="CopyWebviewBundles" BeforeTargets="Build">
61134
<ItemGroup>
62-
<_WebviewBundle Include="..\..\vscode-extension\dist\webview\details.js" />
63-
<_WebviewBundle Include="..\..\vscode-extension\dist\webview\chart.js" />
64-
<_WebviewBundle Include="..\..\vscode-extension\dist\webview\usage.js" />
65-
<_WebviewBundle Include="..\..\vscode-extension\dist\webview\diagnostics.js" />
135+
<_WebviewBundle Include="..\..\..\vscode-extension\dist\webview\details.js" />
136+
<_WebviewBundle Include="..\..\..\vscode-extension\dist\webview\chart.js" />
137+
<_WebviewBundle Include="..\..\..\vscode-extension\dist\webview\usage.js" />
138+
<_WebviewBundle Include="..\..\..\vscode-extension\dist\webview\diagnostics.js" />
66139
</ItemGroup>
67140
<MakeDir Directories="$(MSBuildProjectDirectory)\webview" />
68-
<Copy
69-
SourceFiles="@(_WebviewBundle)"
70-
DestinationFolder="$(MSBuildProjectDirectory)\webview\"
71-
SkipUnchangedFiles="true"
72-
ContinueOnError="true" />
73-
<Message Importance="high"
74-
Text="Copied webview bundles from vscode-extension/dist/webview/ — rebuild vscode-extension if they are missing." />
141+
<Copy SourceFiles="@(_WebviewBundle)" DestinationFolder="$(MSBuildProjectDirectory)\webview\" SkipUnchangedFiles="true" ContinueOnError="true" />
142+
<Message Importance="high" Text="Copied webview bundles from vscode-extension/dist/webview/ — rebuild vscode-extension if they are missing." />
75143
</Target>
76144

77145
<!-- Include copied webview JS files inside the VSIX package -->

visualstudio-extension/src/CopilotTokenTracker/CopilotTokenTrackerPackage.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ protected override async Task InitializeAsync(
3434
{
3535
await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
3636
await Commands.ShowTokenTrackerCommand.InitializeAsync(this);
37+
38+
await this.ShowToolWindowAsync(
39+
typeof(ToolWindow.TokenTrackerToolWindow),
40+
id: 0,
41+
create: true,
42+
cancellationToken: cancellationToken);
3743
}
3844
}
3945
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyTitle("CopilotTokenTracker")]
5+
[assembly: AssemblyDescription("Shows GitHub Copilot token usage statistics inside Visual Studio.")]
6+
[assembly: AssemblyConfiguration("")]
7+
[assembly: AssemblyCompany("RobBos")]
8+
[assembly: AssemblyProduct("CopilotTokenTracker")]
9+
[assembly: AssemblyCopyright("")]
10+
[assembly: AssemblyTrademark("")]
11+
[assembly: AssemblyCulture("")]
12+
13+
[assembly: ComVisible(false)]
14+
15+
[assembly: AssemblyVersion("1.0.0.0")]
16+
[assembly: AssemblyFileVersion("1.0.0.0")]

visualstudio-extension/src/CopilotTokenTracker/Properties/Settings.Designer.cs

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
3+
<Profiles>
4+
<Profile Name="(Default)" />
5+
</Profiles>
6+
</SettingsFile>
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)