FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CSharpCodeAnalyst/CSharpCodeAnalyst/App.xaml.cs at type-cohesion · ATrefzer/CSharpCodeAnalyst · GitHub
ATrefzer
/
CSharpCodeAnalyst
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
11
Code
Issues
0
Pull requests
4
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
CSharpCodeAnalyst
/
CSharpCodeAnalyst
/
App.xaml.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
186 lines (153 loc) · 7.79 KB
Breadcrumbs
CSharpCodeAnalyst
/
CSharpCodeAnalyst
/
App.xaml.cs
Copy path
File metadata and controls
186 lines (153 loc) · 7.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
using
System
.
Diagnostics
;
using
System
.
IO
;
using
System
.
Windows
;
using
CSharpCodeAnalyst
.
AnalyzerSdk
.
Messages
;
using
CSharpCodeAnalyst
.
CodeGraph
.
Exploration
;
using
CSharpCodeAnalyst
.
CodeParser
.
Parser
;
using
CSharpCodeAnalyst
.
CommandLine
;
using
CSharpCodeAnalyst
.
Configuration
;
using
CSharpCodeAnalyst
.
Features
.
AdvancedSearch
;
using
CSharpCodeAnalyst
.
Persistence
.
Json
;
using
CSharpCodeAnalyst
.
Resources
;
using
CSharpCodeAnalyst
.
Features
.
Analyzers
;
using
CSharpCodeAnalyst
.
Features
.
Graph
;
using
CSharpCodeAnalyst
.
Features
.
Info
;
using
CSharpCodeAnalyst
.
Features
.
Mcp
;
using
CSharpCodeAnalyst
.
Mcp
;
using
CSharpCodeAnalyst
.
Features
.
Refactoring
;
using
CSharpCodeAnalyst
.
Features
.
Tree
;
using
CSharpCodeAnalyst
.
Shared
.
Messages
;
using
CSharpCodeAnalyst
.
Shared
.
Notifications
;
using
CSharpCodeAnalyst
.
Shared
.
Services
;
using
Microsoft
.
Extensions
.
Configuration
;
namespace
CSharpCodeAnalyst
;
public
partial
class
App
{
private
McpServerService
?
_mcpServerService
;
protected
override
async
void
OnStartup
(
StartupEventArgs
e
)
{
base
.
OnStartup
(
e
)
;
// Check if command line arguments are provided
if
(
e
.
Args
.
Length
>
1
)
{
// Run in command-line mode.
// ConsoleHelper.EnsureConsole();
var
exitCode
=
await
CommandLineProcessor
.
ProcessCommandLine
(
e
.
Args
)
;
Environment
.
Exit
(
exitCode
)
;
return
;
}
// Run in UI mode
StartUi
(
)
;
// Faster debugging
await
LoadProjectFileFromCommandLineAsync
(
e
)
;
}
protected
override
void
OnExit
(
ExitEventArgs
e
)
{
_mcpServerService
?
.
StopWithoutWaiting
(
)
;
base
.
OnExit
(
e
)
;
}
private
async
Task
LoadProjectFileFromCommandLineAsync
(
StartupEventArgs
e
)
{
const
string
prefix
=
"-load:"
;
if
(
e
.
Args
.
Length
==
1
&&
e
.
Args
[
0
]
.
StartsWith
(
prefix
)
)
{
var
file
=
e
.
Args
[
0
]
[
prefix
.
Length
..
]
;
if
(
!
File
.
Exists
(
file
)
)
{
return
;
}
// Allow loading a project file (json) via command line for faster debugging
if
(
MainWindow
?
.
DataContext
is
MainViewModel
dc
)
{
await
dc
.
LoadProjectFileAsync
(
file
)
;
}
}
}
private
void
StartUi
(
)
{
// const int delayMs = 200;
// ToolTipService.InitialShowDelayProperty.OverrideMetadata(
// typeof(DependencyObject),
// new FrameworkPropertyMetadata(delayMs));
// ToolTipService.BetweenShowDelayProperty.OverrideMetadata(
// typeof(DependencyObject),
// new FrameworkPropertyMetadata(delayMs));
try
{
Initializer
.
InitializeMsBuildLocator
(
)
;
}
catch
(
Exception
ex
)
{
MessageBox
.
Show
(
ex
.
ToString
(
)
)
;
}
// Load application settings
var
builder
=
new
ConfigurationBuilder
(
)
.
SetBasePath
(
Directory
.
GetCurrentDirectory
(
)
)
.
AddJsonFile
(
"appsettings.json"
,
false
,
true
)
;
IConfiguration
configuration
=
builder
.
Build
(
)
;
var
applicationSettings
=
configuration
.
GetSection
(
"ApplicationSettings"
)
.
Get
<
AppSettings
>
(
)
;
if
(
applicationSettings
is
null
)
{
applicationSettings
=
new
AppSettings
(
)
;
}
var
userSettings
=
UserPreferences
.
LoadOrCreate
(
)
;
SourceLocationNavigator
.
PreferredEditor
=
userSettings
.
PreferredEditor
;
var
uiNotification
=
new
WindowsUserNotification
(
)
;
var
messaging
=
new
MessageBus
(
)
;
// Shared store for optional per-member source metrics: filled by MainViewModel on import /
// project load, read by the Method Complexity analyzer.
var
metricStore
=
new
CodeGraph
.
Metrics
.
MetricStore
(
)
;
// Same shape: which members implement a contract from outside the analyzed code. Read by the
// Dead Code analyzer, which would otherwise report every framework override as unused.
var
externalContractStore
=
new
CodeGraph
.
Declarations
.
ExternalContractStore
(
)
;
var
analyzerManager
=
new
AnalyzerManager
(
)
;
analyzerManager
.
LoadAnalyzers
(
messaging
,
uiNotification
,
metricStore
,
externalContractStore
)
;
var
explorer
=
new
CodeGraphExplorer
(
)
;
var
mainWindow
=
new
MainWindow
(
)
;
// The shared, render-agnostic model the web view observes and drives.
var
graphViewState
=
new
GraphViewState
(
)
;
// Graph search reads/writes the shared GraphViewState (search highlights live in
// PresentationState, which the web view renders).
var
graphSearchViewModel
=
new
GraphSearchViewModel
(
graphViewState
)
;
var
refactoringInteraction
=
new
RefactoringInteraction
(
)
;
var
refactoringService
=
new
RefactoringService
(
refactoringInteraction
,
messaging
)
;
mainWindow
.
Initialize
(
graphViewState
,
messaging
,
messaging
,
applicationSettings
,
uiNotification
)
;
var
projectStorage
=
new
JsonProjectStorage
(
)
;
var
projectService
=
new
ProjectService
(
projectStorage
,
uiNotification
,
userSettings
)
;
// Hands the MCP server a copy of the loaded graph. Created unconditionally: it costs nothing
// until something asks it for a snapshot, and MainViewModel notifies it either way.
var
mcpSnapshotProvider
=
new
CodeGraphSnapshotProvider
(
Dispatcher
)
;
var
mcpServerService
=
new
McpServerService
(
applicationSettings
,
mcpSnapshotProvider
,
uiNotification
)
;
_mcpServerService
=
mcpServerService
;
var
viewModel
=
new
MainViewModel
(
messaging
,
applicationSettings
,
userSettings
,
analyzerManager
,
refactoringService
,
projectService
,
metricStore
,
externalContractStore
,
mcpSnapshotProvider
,
mcpServerService
)
;
var
graphViewModel
=
new
GraphViewModel
(
graphViewState
,
explorer
,
messaging
,
applicationSettings
,
refactoringService
)
;
var
treeViewModel
=
new
TreeViewModel
(
messaging
,
refactoringService
)
;
var
searchViewModel
=
new
AdvancedSearchViewModel
(
messaging
,
refactoringService
)
;
var
infoPanelViewModel
=
new
InfoPanelViewModel
(
)
;
viewModel
.
InfoPanelViewModel
=
infoPanelViewModel
;
viewModel
.
GraphViewModel
=
graphViewModel
;
viewModel
.
TreeViewModel
=
treeViewModel
;
viewModel
.
SearchViewModel
=
searchViewModel
;
viewModel
.
GraphSearchViewModel
=
graphSearchViewModel
;
// Setup messaging
messaging
.
Subscribe
<
LocateInTreeRequest
>
(
mainWindow
.
HandleLocateInTreeRequest
)
;
messaging
.
Subscribe
<
ShowTabularDataRequest
>
(
viewModel
.
HandleShowTabularData
)
;
messaging
.
Subscribe
<
ShowHierarchicalDataRequest
>
(
viewModel
.
HandleShowHierarchicalData
)
;
messaging
.
Subscribe
<
AddNodeToGraphRequest
>
(
graphViewModel
.
HandleAddNodeToGraphRequest
)
;
messaging
.
Subscribe
<
ExploreSelectedRequest
>
(
graphViewModel
.
HandleExploreSelectedRequest
)
;
messaging
.
Subscribe
<
RemoveSelectedElementsRequest
>
(
graphViewModel
.
HandleRemoveSelectedRequest
)
;
messaging
.
Subscribe
<
QuickInfoUpdateRequest
>
(
infoPanelViewModel
.
HandleUpdateQuickInfo
)
;
messaging
.
Subscribe
<
CycleCalculationComplete
>
(
viewModel
.
HandleCycleCalculationComplete
)
;
messaging
.
Subscribe
<
ShowPartitionsRequest
>
(
viewModel
.
HandleShowPartitionsRequest
)
;
messaging
.
Subscribe
<
ShowCycleGroupRequest
>
(
viewModel
.
HandleShowCycleGroupRequest
)
;
messaging
.
Subscribe
<
OpenSourceLocationRequest
>
(
r
=>
SourceLocationNavigator
.
Open
(
r
.
Location
)
)
;
// Refactorings are forwarded to all other view models
messaging
.
Subscribe
<
CodeGraphRefactored
>
(
viewModel
.
HandleCodeGraphRefactored
)
;
// messaging.Subscribe<CodeElementsMoved>(viewModel.HandleCodeGraphRefactored);
// messaging.Subscribe<CodeElementsDeleted>(viewModel.HandleCodeGraphRefactored);
// messaging.Subscribe<CodeElementCreated>(viewModel.HandleCodeGraphRefactored);
mainWindow
.
DataContext
=
viewModel
;
MainWindow
=
mainWindow
;
mainWindow
.
Show
(
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL