Skip to content

Commit e405734

Browse files
Fix build issues introduced by recent package upgrades
- Add Microsoft.Build.Framework 18.4.0 with ExcludeAssets=runtime/PrivateAssets=all to Directory.Packages.props and Integration.Tests project to resolve MSBL001 error introduced by Microsoft.Build.Locator 1.11.2 - Change GuidelineXmlToMD.Test to target net10.0 only (matching the tool project's TargetFramework) to fix NU1201 TFM compatibility restore errors - Fix pre-existing nullable reference errors now surfaced in Tools build: - GuidelineXmlFileReader.cs: null-check Root before iterating, use ?? for attributes - MdExtensions.cs: remove unnecessary ?. on already-validated str parameter - MdText.cs: use ?? string.Empty for ToString() nullable return - GuidelineXmlFileReaderTest.cs: add ! null-forgiving on Directory.GetParent chain Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cf9df0a commit e405734

7 files changed

Lines changed: 14 additions & 9 deletions

File tree

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<ItemGroup>
77
<PackageVersion Include="coverlet.collector" Version="8.0.0" />
88
<PackageVersion Include="IntelliTect.Analyzers" Version="0.2.0" />
9+
<PackageVersion Include="Microsoft.Build.Framework" Version="18.4.0" />
910
<PackageVersion Include="Microsoft.Build.Locator" Version="1.11.2" />
1011
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0" />
1112
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />

IntelliTect.Analyzer/IntelliTect.Analyzer.Integration.Tests/IntelliTect.Analyzer.Integration.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>
1616

17+
<PackageReference Include="Microsoft.Build.Framework" ExcludeAssets="runtime" PrivateAssets="all" />
1718
<PackageReference Include="Microsoft.Build.Locator" />
1819
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
1920
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />

Tools/XMLtoMD/GuidelineXmlToMD.Test/GuidelineXmlFileReaderTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class GuidelineXmlFileReaderTest
1313
public void ReadExisitingGuidelinesFile_ExistingFile_ReadsGuidlines()
1414
{
1515
// Arrange
16-
var projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName;
16+
var projectPath = Directory.GetParent(Environment.CurrentDirectory)!.Parent!.Parent!.FullName;
1717
var testPath = Path.Combine(projectPath, @"Data\", "TestGuidelines.xml");
1818

1919
// Act

Tools/XMLtoMD/GuidelineXmlToMD.Test/GuidelineXmlToMD.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
4+
<TargetFramework>net10.0</TargetFramework>
55
<NoWarn>CA2007,CA1815,CA1303,CA1707,CA1305,IDE0008,INTL0003</NoWarn>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

Tools/XMLtoMD/GuidelineXmlToMD/GuidelineXmlFileReader.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ public static ICollection<Guideline> ReadExisitingGuidelinesFile(string pathToEx
1919

2020
HashSet<Guideline> guidelines = [];
2121

22+
if (previousGuidelines.Root is null)
23+
return guidelines;
24+
2225
foreach (XElement guidelineFromXml in previousGuidelines.Root.DescendantNodes().OfType<XElement>())
2326
{
2427
Guideline guideline = new Guideline(
25-
Key: guidelineFromXml.Attribute(_Key)?.Value,
26-
Text: guidelineFromXml?.Value,
27-
Severity: guidelineFromXml.Attribute(_Severity)?.Value,
28-
Section: guidelineFromXml.Attribute(_Section)?.Value,
29-
Subsection: guidelineFromXml.Attribute(_Subsection)?.Value
28+
Key: guidelineFromXml.Attribute(_Key)?.Value ?? string.Empty,
29+
Text: guidelineFromXml.Value,
30+
Severity: guidelineFromXml.Attribute(_Severity)?.Value ?? string.Empty,
31+
Section: guidelineFromXml.Attribute(_Section)?.Value ?? string.Empty,
32+
Subsection: guidelineFromXml.Attribute(_Subsection)?.Value ?? string.Empty
3033
);
3134
guidelines.Add(guideline);
3235
}

Tools/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static string StyleSubstring(this string str, string substring, MdStyle s
3434
}
3535

3636
if (!firstOnly) {
37-
return str?.Replace(substring, MdText.Style(substring, style), System.StringComparison.Ordinal);
37+
return str.Replace(substring, MdText.Style(substring, style), System.StringComparison.Ordinal);
3838
}
3939
int pos = str.IndexOf(substring, System.StringComparison.Ordinal);
4040
if (pos < 0) {

Tools/XMLtoMD/GuidelineXmlToMD/MarkdownOut/MdText.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static string Format(object text, MdFormat format) {
159159

160160
public static string RemoveInvalidMDLinkCharacters(object text)
161161
{
162-
return Regex.Replace(text.ToString(), "[^A-Za-z]", "");
162+
return Regex.Replace(text.ToString() ?? string.Empty, "[^A-Za-z]", "");
163163
}
164164

165165
/// <summary>

0 commit comments

Comments
 (0)