Skip to content

Update and fix issues around xdocument get attribute - #367

Merged
perkops merged 4 commits into
mainfrom
hotfix/xdocument-get-attributes
Aug 25, 2026
Merged

Update and fix issues around xdocument get attribute#367
perkops merged 4 commits into
mainfrom
hotfix/xdocument-get-attributes

Conversation

@davidkallesen

Copy link
Copy Markdown
Collaborator

Summary

Dependency refresh (including a major bump of ICSharpCode.Decompiler), a fix in Atc.DotNet for parsing project files with the legacy MSBuild namespace, and hardening of culture-sensitive unit tests so they no longer depend on the developer's Windows regional settings.
fix(Atc.DotNet): project file parsing
DotnetCsProjFileHelper and DotnetNugetHelper relied on exact XName matching when reading elements/attributes (e.g. Sdk on and package-reference metadata). That fails for project files declaring the legacy MSBuild namespace (http://schemas.microsoft.com/developer/msbuild/2003) and was sensitive to attribute ordering.

  • Attribute and element lookups now match on Name.LocalName, so namespaced and SDK-style project files are handled identically.
  • Lookups are order-independent, so Sdk may appear in any attribute position.
    chore(deps): NuGet updates
  • ICSharpCode.Decompiler 10.1.1.8388 → 11.0.0.9375
  • xunit.v3* 3.2.2 → 4.0.0 (test projects now reference the xunit.v3 meta package instead of xunit.v3.mtp-v2)
  • xunit.runner.visualstudio 3.1.5 → 4.0.0
  • Microsoft.NET.Test.Sdk 18.8.1 → 18.9.0
  • Microsoft.Testing.Extensions.CodeCoverage 18.9.0 → 18.10.0
  • Microsoft.SourceLink.GitHub 10.0.301 → 10.0.400
  • Atc.Test 3.0.0 → 3.1.1
  • Related updates in the Directory.Build.props files and demo projects
    fix(Atc.XUnit): adapt to ICSharpCode.Decompiler 11
    Compile-time changes:
  • AstNode.NodeType / the NodeType enum are no longer accessible — the member filter in DecompilerHelper was replaced with Descendants.OfType().
  • MethodDeclaration.Body is now nullable-annotated — GetAstNodeForMethod / GetAstNodeForMethodWithParameters accept AstNode? and use null-conditional access (fixes CS8604).
    Behavioral regression (found via failing CodeComplianceTests):
  • Decompiler 11 emits out arguments as OutVarDeclarationExpression (TryParse(value, out var _)), where v10 produced a DirectionExpression plus a separate local declaration. As a result, every TryXxx(..., out ...) method was incorrectly reported as "missing tests".
  • DecompilerMethodHelper.GetAstNodesForMethodParameters / FilterDirectChildArguments now treat OutVarDeclarationExpression as an argument node alongside DirectionExpression.
  • ParametersNamingMatchHelper.ParameterCheckForDirectionExpression now also matches OutVarDeclarationExpression for out/ref parameters.
    test: make culture-sensitive tests OS-settings agnostic
    new CultureInfo(lcid) applies the user's Windows regional overrides whenever the requested culture matches the OS culture. On a machine with a customized en-GB format this changed the long-date pattern from dddd, d MMMM yyyy to dd MMMM yyyy, breaking several date tests locally while passing in CI.
    All culture-sensitive tests now use new CultureInfo(lcid, useUserOverride: false):
  • Extensions/BaseTypes/DateTimeExtensionsTests, DateTimeOffsetExtensionsTests, DecimalExtensionsTests, DoubleExtensionsTests, IntegerExtensionsTests, TimeSpanExtensionsTests
  • Helpers/DateTimeHelperTests, DateTimeOffsetHelperTests, NumberHelperTests, Helpers/Enums/DayOfWeekHelperTests
    The CultureInfo JSON converter tests are unchanged — they assert on the CultureInfo object, not on formatting.

…rder-agnostic

DotnetNugetHelper.GetAllPackageReferences looked up PackageReference
elements with Descendants("PackageReference"), a namespace-qualified
lookup. Any project file declaring the legacy MSBuild namespace
(<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">)
therefore yielded zero package references instead of its actual ones.
Element and attribute lookups now match on local name, so both
SDK-style and legacy-namespace files are handled.

The same method also rejected content with a leading blank line or
indentation, throwing DataException("Expect xml content") for perfectly
valid XML. Leading whitespace is now trimmed before the guard, matching
what VisualStudioSolutionFileHelper.TryParseSlnx already does. Genuinely
non-XML input still throws.

DotnetCsProjFileHelper resolved the project SDK through
XElement.FirstAttribute, which is only the Sdk attribute when it happens
to be written first. Both an attribute ordered ahead of it
(<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">) and an xmlns
declaration - which LINQ to XML also exposes as an attribute - made
every SDK comparison fail and GetProjectType silently return
DotnetProjectType.None. The Sdk attribute is now looked up by name via
GetSdk/IsSdk. A missing Sdk attribute is still treated as
not disqualifying, preserving the previous semantics.
@perkops
perkops merged commit 2998124 into main Aug 25, 2026
4 checks passed
@perkops
perkops deleted the hotfix/xdocument-get-attributes branch August 25, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants