File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -271,8 +271,11 @@ private void Parse(string file)
271271 }
272272 break ;
273273 case "import" :
274- isLegacyProjectStructureUsed = isLegacyProjectStructureUsed || reader . GetAttribute ( "Project" ) ? . EndsWith ( "Microsoft.CSharp.targets" , StringComparison . OrdinalIgnoreCase ) == true ;
274+ var project = reader . GetAttribute ( "Project" ) ;
275+ isSdkProjectStructureUsed = isSdkProjectStructureUsed || project is not null && reader . GetAttribute ( "Sdk" ) is not null ;
276+ isLegacyProjectStructureUsed = isLegacyProjectStructureUsed || project ? . EndsWith ( "Microsoft.CSharp.targets" , StringComparison . OrdinalIgnoreCase ) == true ;
275277 break ;
278+ // TODO: we could also check `<Sdk Name="Microsoft.NET.Sdk" />`
276279 }
277280 } ) ;
278281 }
Original file line number Diff line number Diff line change @@ -229,6 +229,24 @@ public void TestFileContent_SdkProjectStructure()
229229 Assert . False ( isLegacy ) ;
230230 }
231231
232+ /// <summary>
233+ /// Verifies that an SDK attribute on an import indicates SDK project structure.
234+ /// </summary>
235+ [ Fact ]
236+ public void TestFileContent_SdkProjectImport ( )
237+ {
238+ // Setup
239+ var fileContent = new TestFileContent ( "<Project><Import Project='Sdk.props' Sdk='Microsoft.NET.Sdk' /></Project>" ) ;
240+
241+ // Execute
242+ var isLegacy = fileContent . IsLegacyProjectStructureUsed ;
243+ var isSdk = fileContent . IsSdkProjectStructureUsed ;
244+
245+ // Verify
246+ Assert . True ( isSdk ) ;
247+ Assert . False ( isLegacy ) ;
248+ }
249+
232250 /// <summary>
233251 /// Verifies that `FileContent` correctly handles XML syntax with namespaces and various elements.
234252 /// </summary>
You can’t perform that action at this time.
0 commit comments