Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump System.Text.RegularExpressions from 4.3.0 to 4.3.1 in /CodeTiger.CodeAnalysis #2

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ if ($SkipDebug) {
}

$roslynVersions = @("2.6", "3.8", "4.0", "4.4")
$latestRoslynVersion = $roslynVersions[-1]
$roslynVersions | Foreach-Object {
$roslynVersion = $_
$configurations | Foreach-Object {
Expand All @@ -87,7 +88,7 @@ $roslynVersions | Foreach-Object {

$slnPath = [IO.Path]::Combine($PSScriptRoot, "CodeTiger.CodeAnalysis.sln")

if (-not $SkipVsix) {
if ($roslynVersion -eq $latestRoslynVersion -and -not $SkipVsix) {

if ($CleanBeforeBuilding) {
Write-Host "Cleaning CodeTiger.CodeAnalysis.sln..." -ForegroundColor Cyan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<TargetFrameworkProfile />
<NoWarn>MSB3243;MSB3277</NoWarn>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -48,7 +49,6 @@
<StartArguments>/rootsuffix Roslyn</StartArguments>
</PropertyGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
</None>
Expand Down
39 changes: 0 additions & 39 deletions CodeTiger.CodeAnalysis.Vsix/app.config

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ bool IsAllowableDiscard()
case SyntaxKind.ParenthesizedLambdaExpression:
case SyntaxKind.SimpleLambdaExpression:
return "_".Equals(parameterNode.Identifier.ValueText, StringComparison.OrdinalIgnoreCase);
case SyntaxKind.ParameterList:
return parameterNode.Parent.Parent?.IsKind(SyntaxKind.ParenthesizedLambdaExpression) == true
&& "_".Equals(parameterNode.Identifier.ValueText, StringComparison.OrdinalIgnoreCase);
default:
return false;
}
Expand Down
7 changes: 6 additions & 1 deletion CodeTiger.CodeAnalysis/CodeTiger.CodeAnalysis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ While not intended to be an exact replacement for StyleCop, many of the individu
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="NETStandard.Library" PrivateAssets="all" />
</ItemGroup>

<!-- Disable warnings for known-vulnerable NuGet packages that this project does not use. -->
<ItemGroup Condition="'$(RoslynVersion)'=='2.6'">
<PackageReference Include="System.Net.Http" Version="4.3.0" NoWarn="NU1903" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" NoWarn="NU1903" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

<!-- Visual Studio 2017 15.5 / C# 7.2 -->
<PropertyGroup Condition="'$(RoslynVersion)'=='2.6'">
<RoslynPackageVersion>2.6.1</RoslynPackageVersion>
<RoslynPackageVersion>4.4.0</RoslynPackageVersion>
<DefineConstants>$(DefineConstants);ROSLYN2_6;ROSLYN2_6_OR_HIGHER</DefineConstants>
</PropertyGroup>

<!-- Visual Studio 2019 16.8 / C# 9.0 -->
<PropertyGroup Condition="'$(RoslynVersion)'=='3.8'">
<RoslynPackageVersion>3.8.0</RoslynPackageVersion>
<RoslynPackageVersion>4.4.0</RoslynPackageVersion>
<DefineConstants>$(DefineConstants);ROSLYN3_8;ROSLYN3_8_OR_HIGHER;ROSLYN2_6_OR_HIGHER</DefineConstants>
</PropertyGroup>

<!-- Visual Studio 2022 17.0 / C# 10.0 -->
<PropertyGroup Condition="'$(RoslynVersion)'=='4.0'">
<RoslynPackageVersion>4.0.1</RoslynPackageVersion>
<RoslynPackageVersion>4.4.0</RoslynPackageVersion>
<DefineConstants>$(DefineConstants);ROSLYN4_0;ROSLYN4_0_OR_HIGHER;ROSLYN3_8_OR_HIGHER;ROSLYN2_6_OR_HIGHER</DefineConstants>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand All @@ -15,9 +15,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(RoslynPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,15 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
{
string diagnosticsOutput = actualResults.Any()
? FormatDiagnostics(analyzer, actualResults.ToArray())
: " NONE.";
: "NONE.";

Assert.True(false,
string.Format("Mismatch between number of diagnostics returned, expected \"{0}\" actual \"{1}"
+ """
"
Assert.Fail(
$"""
Mismatch between number of diagnostics returned, expected {expectedCount}, actual {actualCount}

Diagnostics:
{2}

""", expectedCount, actualCount, diagnosticsOutput));
{diagnosticsOutput}
""");
}

for (int i = 0; i < expectedResults.Length; i++)
Expand All @@ -319,14 +317,13 @@ private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResult
{
if (actual.Location != Location.None)
{
Assert.True(false,
string.Format("""
Expected:
Assert.Fail(
$"""
Expected:
A project diagnostic with No location
Actual:
{0}
""",
FormatDiagnostics(analyzer, actual)));
Actual:
{FormatDiagnostics(analyzer, actual)}
""");
}
}
else
Expand All @@ -336,15 +333,14 @@ A project diagnostic with No location

if (additionalLocations.Length != expected.Locations.Length - 1)
{
Assert.True(false,
string.Format(
"""
Expected {0} additional locations but got {1} for Diagnostic:
{2}

""",
expected.Locations.Length - 1, additionalLocations.Length,
FormatDiagnostics(analyzer, actual)));
expectedCount = expected.Locations.Length - 1;
actualCount = additionalLocations.Length;

Assert.Fail(
$"""
Expected {expectedCount} additional locations but got {actualCount} for Diagnostic:
{FormatDiagnostics(analyzer, actual)}
""");
}

for (int j = 0; j < additionalLocations.Length; ++j)
Expand All @@ -356,48 +352,35 @@ A project diagnostic with No location

if (actual.Id != expected.Id)
{
Assert.True(false,
string.Format(
"""
Expected diagnostic id to be "{0}" was "{1}"

Diagnostic:
{2}
Assert.Fail(
$"""
Expected diagnostic id to be "{expected.Id}" was "{actual.Id}"

""",
expected.Id, actual.Id, FormatDiagnostics(analyzer, actual)));
Diagnostic:
{FormatDiagnostics(analyzer, actual)}
""");
}

if (actual.Severity != expected.Severity)
{
Assert.True(false,
string.Format("""
Expected diagnostic severity to be "{0}" was "{1}"

Diagnostic:
"""
+ """

{2}
Assert.Fail(
$"""
Expected diagnostic severity to be "{expected.Severity}" was "{actual.Severity}"

""", expected.Severity, actual.Severity,
FormatDiagnostics(analyzer, actual)));
Diagnostic:
{FormatDiagnostics(analyzer, actual)}
""");
}

if (actual.GetMessage() != expected.Message)
{
Assert.True(false,
string.Format("""
Expected diagnostic message to be "{0}" was "{1}"
Assert.Fail(
$"""
Expected diagnostic message to be "{expected.Message}" was "{actual.GetMessage()}"

Diagnostic:
"""
+ """

{2}

""", expected.Message, actual.GetMessage(),
FormatDiagnostics(analyzer, actual)));
Diagnostic:
{FormatDiagnostics(analyzer, actual)}
""");
}
}
}
Expand All @@ -415,57 +398,52 @@ private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagno
{
var actualSpan = actual.GetLineSpan();

Assert.True(actualSpan.Path == expected.Path
|| (actualSpan.Path?.Contains("Test0.") == true && expected.Path?.Contains("Test.") == true),
string.Format("""
Expected diagnostic to be in file "{0}" was actually in file "{1}"

bool isSpanCorrect = actualSpan.Path == expected.Path
|| (actualSpan.Path?.Contains("Test0.") == true && expected.Path?.Contains("Test.") == true);

"""
+ """
Diagnostic:
{2}
Assert.True(isSpanCorrect,
$"""
Expected diagnostic to be in file "{expected.Path}" was actually in file "{actualSpan.Path}"

""", expected.Path, actualSpan.Path,
FormatDiagnostics(analyzer, diagnostic)));
Diagnostic:
{FormatDiagnostics(analyzer, diagnostic)}
""");

var actualLinePosition = actualSpan.StartLinePosition;

// Only check line position if there is an actual line in the real diagnostic
if (actualLinePosition.Line > 0)
{
if (actualLinePosition.Line + 1 != expected.Line)
{
Assert.True(false,
string.Format("""
Expected diagnostic to be on line "{0}" was actually on line "{1}"

"""
+ """
int expectedLine = expected.Line;
int actualLine = actualLinePosition.Line + 1;

Diagnostic:
{2}
if (actualLine != expectedLine)
{
Assert.Fail(
$"""
Expected diagnostic to be on line {expectedLine} was actually on line {actualLine}

""", expected.Line, actualLinePosition.Line + 1,
FormatDiagnostics(analyzer, diagnostic)));
Diagnostic:
{FormatDiagnostics(analyzer, diagnostic)}
""");
}
}

// Only check column position if there is an actual column position in the real diagnostic
if (actualLinePosition.Character > 0)
{
if (actualLinePosition.Character + 1 != expected.Column)
{
Assert.True(false,
string.Format("Expected diagnostic to start at column \"{0}\" was actually at column "
+ """
"{1}"
int expectedColumn = expected.Column;
int actualColumn = actualLinePosition.Character + 1;

Diagnostic:
{2}
if (actualColumn != expectedColumn)
{
Assert.Fail(
$"""
Expected diagnostic to start at column {expectedColumn} was actually at column {actualColumn}

""", expected.Column,
actualLinePosition.Character + 1, FormatDiagnostics(analyzer, diagnostic)));
Diagnostic:
{FormatDiagnostics(analyzer, diagnostic)}
""");
}
}
}
Expand Down Expand Up @@ -498,11 +476,8 @@ private static string FormatDiagnostics(DiagnosticAnalyzer analyzer, params Diag
else
{
Assert.True(location.IsInSource,
$"Test base does not currently handle diagnostics in metadata locations."
+ """
Diagnostic in metadata: {diagnostics[i]}

""");
"Test base does not currently handle diagnostics in metadata locations. Diagnostic: "
+ diagnostics[i]);

var sourceTree = location.SourceTree;
string resultMethodName = sourceTree is null || sourceTree.FilePath.EndsWith(".cs") == true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,9 @@ public void DoSomething()
{
var dictionary = new ConcurrentDictionary<int, string>();
dictionary.GetOrAdd(0, _ => "0");
dictionary.GetOrAdd(0, (_) => "0");
Action<object> action = _ => { };
Func<string, bool> func = (_) => true;
}
}
}
Expand All @@ -1050,7 +1053,7 @@ public void DoSomething()
}

[Fact]
public void ParameterWithDiscardNamesWhereNotAllowedProduceDiagnostics()
public void ParametersWithDiscardNamesWhereNotAllowedProduceDiagnostics()
{
string code = """
using System;
Expand Down
Loading
Loading