@@ -24,7 +24,7 @@ suite("Asset generation: csproj", () => {
24
24
let generator = new AssetGenerator ( info , createMockWorkspaceFolder ( rootPath ) ) ;
25
25
generator . setStartupProject ( 0 ) ;
26
26
let tasksJson = generator . createTasksConfiguration ( ) ;
27
- let buildPath = tasksJson . tasks [ 0 ] . args [ 1 ] ;
27
+ let buildPath = tasksJson . tasks ! [ 0 ] . args ! [ 1 ] ;
28
28
29
29
// ${workspaceFolder}/project.json
30
30
let segments = buildPath . split ( path . posix . sep ) ;
@@ -39,9 +39,9 @@ suite("Asset generation: csproj", () => {
39
39
let tasksJson = generator . createTasksConfiguration ( ) ;
40
40
41
41
// We do not check the watch task since this parameter can break hot reload scenarios.
42
- tasksJson . tasks
42
+ tasksJson . tasks !
43
43
. filter ( task => task . label !== "watch" )
44
- . forEach ( task => task . args . should . contain ( "/property:GenerateFullPaths=true" ) ) ;
44
+ . forEach ( task => task . args ! . should . contain ( "/property:GenerateFullPaths=true" ) ) ;
45
45
} ) ;
46
46
47
47
test ( "Generated 'build' and 'publish' tasks have the consoleloggerparameters argument set to NoSummary" , ( ) => {
@@ -52,9 +52,9 @@ suite("Asset generation: csproj", () => {
52
52
let tasksJson = generator . createTasksConfiguration ( ) ;
53
53
54
54
// We do not check the watch task since this parameter can break hot reload scenarios.
55
- tasksJson . tasks
55
+ tasksJson . tasks !
56
56
. filter ( task => task . label !== "watch" )
57
- . forEach ( task => task . args . should . contain ( "/consoleloggerparameters:NoSummary" ) ) ;
57
+ . forEach ( task => task . args ! . should . contain ( "/consoleloggerparameters:NoSummary" ) ) ;
58
58
} ) ;
59
59
60
60
test ( "Generated 'watch' task does not have the property GenerateFullPaths set to true " , ( ) => {
@@ -64,8 +64,8 @@ suite("Asset generation: csproj", () => {
64
64
generator . setStartupProject ( 0 ) ;
65
65
let tasksJson = generator . createTasksConfiguration ( ) ;
66
66
67
- const watchTask = tasksJson . tasks . find ( task => task . label === "watch" ) ;
68
- watchTask . args . should . not . contain ( "/property:GenerateFullPaths=true" ) ;
67
+ const watchTask = tasksJson . tasks ! . find ( task => task . label === "watch" ) ;
68
+ watchTask ! . args ! . should . not . contain ( "/property:GenerateFullPaths=true" ) ;
69
69
} ) ;
70
70
71
71
test ( "Generated 'watch' task does not have the consoleloggerparameters argument set to NoSummary" , ( ) => {
@@ -75,8 +75,8 @@ suite("Asset generation: csproj", () => {
75
75
generator . setStartupProject ( 0 ) ;
76
76
let tasksJson = generator . createTasksConfiguration ( ) ;
77
77
78
- const watchTask = tasksJson . tasks . find ( task => task . label === "watch" ) ;
79
- watchTask . args . should . not . contain ( "/consoleloggerparameters:NoSummary" ) ;
78
+ const watchTask = tasksJson . tasks ! . find ( task => task . label === "watch" ) ;
79
+ watchTask ! . args ! . should . not . contain ( "/consoleloggerparameters:NoSummary" ) ;
80
80
} ) ;
81
81
82
82
test ( "Create tasks.json for nested project opened in workspace" , ( ) => {
@@ -85,7 +85,7 @@ suite("Asset generation: csproj", () => {
85
85
let generator = new AssetGenerator ( info , createMockWorkspaceFolder ( rootPath ) ) ;
86
86
generator . setStartupProject ( 0 ) ;
87
87
let tasksJson = generator . createTasksConfiguration ( ) ;
88
- let buildPath = tasksJson . tasks [ 0 ] . args [ 1 ] ;
88
+ let buildPath = tasksJson . tasks ! [ 0 ] . args ! [ 1 ] ;
89
89
90
90
// ${workspaceFolder}/nested/project.json
91
91
let segments = buildPath . split ( path . posix . sep ) ;
@@ -100,7 +100,7 @@ suite("Asset generation: csproj", () => {
100
100
let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Console ) , undefined , { disallowComments : true } ) ;
101
101
let programPath : string = launchJson [ 0 ] . program ;
102
102
103
- checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
103
+ checkProgramPath ( rootPath , programPath , info . MsBuild ! . Projects [ 0 ] . TargetPath ) ;
104
104
} ) ;
105
105
106
106
[ 5 , 6 , 7 , 8 , 9 ] . forEach ( version => {
@@ -114,7 +114,7 @@ suite("Asset generation: csproj", () => {
114
114
let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Console ) , undefined , { disallowComments : true } ) ;
115
115
let programPath : string = launchJson [ 0 ] . program ;
116
116
117
- checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
117
+ checkProgramPath ( rootPath , programPath , info . MsBuild ! . Projects [ 0 ] . TargetPath ) ;
118
118
} ) ;
119
119
} ) ;
120
120
@@ -126,7 +126,7 @@ suite("Asset generation: csproj", () => {
126
126
let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Console ) , undefined , { disallowComments : true } ) ;
127
127
let programPath : string = launchJson [ 0 ] . program ;
128
128
129
- checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
129
+ checkProgramPath ( rootPath , programPath , info . MsBuild ! . Projects [ 0 ] . TargetPath ) ;
130
130
} ) ;
131
131
132
132
test ( "Create launch.json for project opened in workspace with non-relative output path" , function ( ) {
@@ -142,7 +142,7 @@ suite("Asset generation: csproj", () => {
142
142
let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Console ) , undefined , { disallowComments : true } ) ;
143
143
let programPath : string = launchJson [ 0 ] . program ;
144
144
145
- checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
145
+ checkProgramPath ( rootPath , programPath , info . MsBuild ! . Projects [ 0 ] . TargetPath ) ;
146
146
} ) ;
147
147
148
148
test ( "Create launch.json for Blazor web assembly standalone project opened in workspace" , ( ) => {
@@ -180,7 +180,7 @@ suite("Asset generation: csproj", () => {
180
180
const cwd = hostedBlazorLaunchConfig . cwd ;
181
181
const hosted = hostedBlazorLaunchConfig . hosted ;
182
182
183
- checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
183
+ checkProgramPath ( rootPath , programPath , info . MsBuild ! . Projects [ 0 ] . TargetPath ) ;
184
184
185
185
cwd . should . equal ( '${workspaceFolder}' ) ;
186
186
hosted . should . equal ( true ) ;
@@ -197,7 +197,7 @@ suite("Asset generation: csproj", () => {
197
197
const cwd = hostedBlazorLaunchConfig . cwd ;
198
198
const hosted = hostedBlazorLaunchConfig . hosted ;
199
199
200
- checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
200
+ checkProgramPath ( rootPath , programPath , info . MsBuild ! . Projects [ 0 ] . TargetPath ) ;
201
201
202
202
cwd . should . equal ( '${workspaceFolder}/nested' ) ;
203
203
hosted . should . equal ( true ) ;
@@ -211,7 +211,7 @@ suite("Asset generation: csproj", () => {
211
211
let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Web ) , undefined , { disallowComments : true } ) ;
212
212
let programPath : string = launchJson [ 0 ] . program ;
213
213
214
- checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
214
+ checkProgramPath ( rootPath , programPath , info . MsBuild ! . Projects [ 0 ] . TargetPath ) ;
215
215
} ) ;
216
216
217
217
test ( "Create launch.json for nested web project opened in workspace" , ( ) => {
@@ -222,7 +222,7 @@ suite("Asset generation: csproj", () => {
222
222
let launchJson = parse ( generator . createLaunchJsonConfigurations ( ProgramLaunchType . Web ) , undefined , { disallowComments : true } ) ;
223
223
let programPath : string = launchJson [ 0 ] . program ;
224
224
225
- checkProgramPath ( rootPath , programPath , info . MsBuild . Projects [ 0 ] . TargetPath ) ;
225
+ checkProgramPath ( rootPath , programPath , info . MsBuild ! . Projects [ 0 ] . TargetPath ) ;
226
226
} ) ;
227
227
228
228
test ( "Add a new item to JSON" , ( ) => {
@@ -234,7 +234,7 @@ suite("Asset generation: csproj", () => {
234
234
} ;
235
235
236
236
const newItem = { name : 'new-item' } ;
237
- const updated = updateJsonWithComments ( JSON . stringify ( original ) , [ newItem ] , 'configurations' , 'name' , /*formattingOptions*/ null ) ;
237
+ const updated = updateJsonWithComments ( JSON . stringify ( original ) , [ newItem ] , 'configurations' , 'name' , /*formattingOptions*/ null ! ) ;
238
238
const parsed = jsonc . parse ( updated ) ;
239
239
const configurations = parsed . configurations ;
240
240
@@ -254,7 +254,7 @@ suite("Asset generation: csproj", () => {
254
254
255
255
const updatedItem = { name : 'build' , command : 'dotnet' } ;
256
256
257
- const updated = updateJsonWithComments ( JSON . stringify ( original ) , [ updatedItem ] , 'configurations' , 'name' , /*formattingOptions*/ null ) ;
257
+ const updated = updateJsonWithComments ( JSON . stringify ( original ) , [ updatedItem ] , 'configurations' , 'name' , /*formattingOptions*/ null ! ) ;
258
258
const parsed = jsonc . parse ( updated ) ;
259
259
const configurations = parsed . configurations ;
260
260
@@ -278,7 +278,7 @@ suite("Asset generation: csproj", () => {
278
278
279
279
const updatedItem = { name : 'build' , command : 'dotnet' } ;
280
280
281
- const updated = updateJsonWithComments ( original , [ updatedItem ] , 'configurations' , 'name' , /*formattingOptions*/ null ) ;
281
+ const updated = updateJsonWithComments ( original , [ updatedItem ] , 'configurations' , 'name' , /*formattingOptions*/ null ! ) ;
282
282
const lines = updated . trim ( ) . split ( '\n' ) ;
283
283
284
284
lines [ 0 ] . trim ( ) . should . equal ( '// user comment in file' ) ;
@@ -336,12 +336,12 @@ function checkProgramPath(rootPath: string, programPath: string, targetPath: str
336
336
function createMockWorkspaceFolder ( rootPath : string ) : vscode . WorkspaceFolder {
337
337
return {
338
338
uri : vscode . Uri . file ( rootPath ) ,
339
- name : undefined ,
340
- index : undefined
339
+ name : '' ,
340
+ index : - 1
341
341
} ;
342
342
}
343
343
344
- function createMSBuildWorkspaceInformation ( projectPath : string , assemblyName : string , targetFrameworkShortName : string , targetPath : string = undefined , isExe : boolean = true , isWebProject : boolean = false , isBlazorWebAssemblyStandalone : boolean = false , isBlazorWebAssemblyHosted : boolean = false ) : protocol . WorkspaceInformationResponse {
344
+ function createMSBuildWorkspaceInformation ( projectPath : string , assemblyName : string , targetFrameworkShortName : string , targetPath : string | undefined = undefined , isExe : boolean = true , isWebProject : boolean = false , isBlazorWebAssemblyStandalone : boolean = false , isBlazorWebAssemblyHosted : boolean = false ) : protocol . WorkspaceInformationResponse {
345
345
return {
346
346
MsBuild : {
347
347
SolutionPath : '' ,
0 commit comments