dependabot-nuget 0.350.0 → 0.351.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 784c940d61ac0b10f0d1b6516c7b33bbaa6e8de03da294ee43245746303e24bb
4
- data.tar.gz: 6fddc772c732c7a21c56121fdf90f35d668cc6ce3c5662ae134d6060ae55f291
3
+ metadata.gz: 92efa07f7e605aa2eb40dac6c6a7d37c03ce873a4efddd3136376be0ca71afb1
4
+ data.tar.gz: 5e880e74afa472592ca16e19b058b57e0463d15e8146f034f1bc426806f14162
5
5
  SHA512:
6
- metadata.gz: 82b32710529925d9392c82d7403ad91eea8445f3ef734190a1175ed56a60bd9a2f338f7066956c5074f1478e4f57ff36b94a1670fabc77a068a8362aee442bf7
7
- data.tar.gz: 6b5c2ed6e27c43f1c9f264a6dd749f42fc71018e308a66484aa6aa734dfa232e845be87c75797cb0f8cff8a54e71f164f56fb07394faf7ac0fdcfc776713f007
6
+ metadata.gz: fc9a268d0f08a5eb1bcaae66529c4ee27c8f9d076ecc9ea26fa337fed43378323640bb253f262b8409e7543c1af24e0f676f901e90ee61d5d1217b9f1b767bee
7
+ data.tar.gz: c180e625532335e826a836597a022d1c21c117702ce9e7cc2dddf42d833df0a78d0ab9d37b81f251d62fcc53e12d6a568f9941b3ce03518d7243394580eb7b14
@@ -22,6 +22,8 @@ public class XmlFileWriter : IFileWriter
22
22
  private const string PackageVersionElementName = "PackageVersion";
23
23
  private const string PropertyGroupElementName = "PropertyGroup";
24
24
 
25
+ private const string UpdaterAnnotationKind = "dependabot";
26
+
25
27
  private readonly ILogger _logger;
26
28
 
27
29
  // these file extensions are valid project entrypoints; everything else is ignored
@@ -357,10 +359,11 @@ public class XmlFileWriter : IFileWriter
357
359
  currentVersionString = versionAttribute.Value;
358
360
  updateVersionLocation = version =>
359
361
  {
362
+ var existingAnnotation = versionAttribute.GetAnnotations(UpdaterAnnotationKind).First();
360
363
  var refoundVersionAttribute = filesAndContents[filePath]
361
364
  .DescendantNodes()
362
365
  .OfType<XmlAttributeSyntax>()
363
- .First(a => a.FullSpan.Start == versionAttribute.FullSpan.Start);
366
+ .First(a => a.GetAnnotations(UpdaterAnnotationKind).Any(an => an == existingAnnotation));
364
367
  ReplaceNode(filePath, refoundVersionAttribute, refoundVersionAttribute.WithValue(version));
365
368
  };
366
369
  goto doVersionUpdate;
@@ -373,10 +376,11 @@ public class XmlFileWriter : IFileWriter
373
376
  currentVersionString = versionElement.GetContentValue();
374
377
  updateVersionLocation = version =>
375
378
  {
379
+ var existingAnnotation = versionElement.AsNode.GetAnnotations(UpdaterAnnotationKind).First();
376
380
  var refoundVersionElement = filesAndContents[filePath]
377
381
  .DescendantNodes()
378
382
  .OfType<IXmlElementSyntax>()
379
- .First(e => e.AsNode.FullSpan.Start == versionElement.AsNode.FullSpan.Start);
383
+ .First(e => e.AsNode.GetAnnotations(UpdaterAnnotationKind).Any(an => an == existingAnnotation));
380
384
  ReplaceNode(filePath, refoundVersionElement.AsNode, refoundVersionElement.WithContent(version).AsNode);
381
385
  };
382
386
  goto doVersionUpdate;
@@ -556,7 +560,18 @@ public class XmlFileWriter : IFileWriter
556
560
  var fullPath = Path.Join(repoContentsPath.FullName, path);
557
561
  var contents = await File.ReadAllTextAsync(fullPath);
558
562
  var document = Parser.ParseText(contents);
559
- return document;
563
+
564
+ // ensure relevant nodes have a unique annotation so we can do precise edits later
565
+ var documentWithAllAnnotations = document.ReplaceNodes(
566
+ document.DescendantNodes(),
567
+ (_, node) => node switch
568
+ {
569
+ var nodeType when nodeType is XmlAttributeSyntax or XmlElementSyntax
570
+ => node.WithAnnotations(new SyntaxAnnotation(UpdaterAnnotationKind)),
571
+ _ => node,
572
+ });
573
+
574
+ return documentWithAllAnnotations;
560
575
  }
561
576
 
562
577
  private static async Task WriteFileContentsAsync(DirectoryInfo repoContentsPath, string path, XmlDocumentSyntax document)
@@ -1833,4 +1833,78 @@ public class XmlFileWriterTests : FileWriterTestsBase
1833
1833
  ]
1834
1834
  );
1835
1835
  }
1836
+
1837
+ [Fact]
1838
+ public async Task MultipleEdits_AttributeSpansChange()
1839
+ {
1840
+ await TestAsync(
1841
+ files: [
1842
+ ("project.csproj", """
1843
+ <Project Sdk="Microsoft.NET.Sdk">
1844
+ <ItemGroup Condition="'$(Configuration)' == 'Release'">
1845
+ <PackageReference Include="Some.Dependency" Version="9.0.0" />
1846
+ </ItemGroup>
1847
+ <ItemGroup Condition="'$(Configuration)' == 'Debug'">
1848
+ <PackageReference Include="Some.Dependency" Version="9.0.0" />
1849
+ </ItemGroup>
1850
+ </Project>
1851
+ """)
1852
+ ],
1853
+ initialProjectDependencyStrings: ["Some.Dependency/9.0.0"],
1854
+ requiredDependencyStrings: ["Some.Dependency/10.0.0"],
1855
+ expectedFiles: [
1856
+ ("project.csproj", """
1857
+ <Project Sdk="Microsoft.NET.Sdk">
1858
+ <ItemGroup Condition="'$(Configuration)' == 'Release'">
1859
+ <PackageReference Include="Some.Dependency" Version="10.0.0" />
1860
+ </ItemGroup>
1861
+ <ItemGroup Condition="'$(Configuration)' == 'Debug'">
1862
+ <PackageReference Include="Some.Dependency" Version="10.0.0" />
1863
+ </ItemGroup>
1864
+ </Project>
1865
+ """)
1866
+ ]
1867
+ );
1868
+ }
1869
+
1870
+ [Fact]
1871
+ public async Task MultipleEdits_ElementSpansChange()
1872
+ {
1873
+ await TestAsync(
1874
+ files: [
1875
+ ("project.csproj", """
1876
+ <Project Sdk="Microsoft.NET.Sdk">
1877
+ <ItemGroup Condition="'$(Configuration)' == 'Release'">
1878
+ <PackageReference Include="Some.Dependency">
1879
+ <Version>9.0.0</Version>
1880
+ </PackageReference>
1881
+ </ItemGroup>
1882
+ <ItemGroup Condition="'$(Configuration)' == 'Debug'">
1883
+ <PackageReference Include="Some.Dependency">
1884
+ <Version>9.0.0</Version>
1885
+ </PackageReference>
1886
+ </ItemGroup>
1887
+ </Project>
1888
+ """)
1889
+ ],
1890
+ initialProjectDependencyStrings: ["Some.Dependency/9.0.0"],
1891
+ requiredDependencyStrings: ["Some.Dependency/10.0.0"],
1892
+ expectedFiles: [
1893
+ ("project.csproj", """
1894
+ <Project Sdk="Microsoft.NET.Sdk">
1895
+ <ItemGroup Condition="'$(Configuration)' == 'Release'">
1896
+ <PackageReference Include="Some.Dependency">
1897
+ <Version>10.0.0</Version>
1898
+ </PackageReference>
1899
+ </ItemGroup>
1900
+ <ItemGroup Condition="'$(Configuration)' == 'Debug'">
1901
+ <PackageReference Include="Some.Dependency">
1902
+ <Version>10.0.0</Version>
1903
+ </PackageReference>
1904
+ </ItemGroup>
1905
+ </Project>
1906
+ """)
1907
+ ]
1908
+ );
1909
+ }
1836
1910
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-nuget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.350.0
4
+ version: 0.351.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.350.0
18
+ version: 0.351.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.350.0
25
+ version: 0.351.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -552,7 +552,7 @@ licenses:
552
552
  - MIT
553
553
  metadata:
554
554
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
555
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.350.0
555
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.351.0
556
556
  rdoc_options: []
557
557
  require_paths:
558
558
  - lib