Skip to content

Commit e9674ea

Browse files
author
MPCoreDeveloper
committed
multiple changes for second community notes response
1 parent 269c5e3 commit e9674ea

File tree

8 files changed

+241
-68
lines changed

8 files changed

+241
-68
lines changed

Posseth.NamedArguments.AnalyzerAndFixer.Package/Posseth.NamedArguments.AnalyzerAndFixer.Package.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99

1010
<PropertyGroup>
1111
<PackageId>Posseth.NamedArguments.AnalyzerAndFixer</PackageId>
12-
<PackageVersion>1.0.1.0</PackageVersion>
12+
<PackageVersion>1.0.1.1</PackageVersion>
1313
<Authors>MPCoreDeveloper</Authors>
1414
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1515
<PackageProjectUrl>https://github.com/MPCoreDeveloper/Posseth.NamedArguments.AnalyzerAndFixer</PackageProjectUrl>
1616
<RepositoryUrl>https://github.com/MPCoreDeveloper/Posseth.NamedArguments.AnalyzerAndFixer</RepositoryUrl>
1717
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1818
<Description>This tool analyzes method calls to ensure they use named arguments and provides an option to automatically convert positional arguments to named arguments. For example, it can transform `TestMethod(1, 2)` into `TestMethod(x: 1, y: 2)`.
1919
</Description>
20-
<PackageReleaseNotes>release with comunity feedback improvements</PackageReleaseNotes>
20+
<PackageReleaseNotes>release with new settings and customizations</PackageReleaseNotes>
2121
<Copyright>Free to use , distribute and modify </Copyright>
2222
<PackageTags>NamedArguments;AnalyzerAndFixer;analyzers;</PackageTags>
2323
<DevelopmentDependency>true</DevelopmentDependency>
2424
<NoPackageAnalysis>true</NoPackageAnalysis>
2525
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddAnalyzersToOutput</TargetsForTfmSpecificContentInPackage>
2626
<Title>Named Arguments Analyzer and Fixer</Title>
27-
<Version>1.1.0</Version>
27+
<Version>1.1.1</Version>
2828
<Company>Posseth Software</Company>
2929
<Product>Posseth.NamedArguments.AnalyzerAndFixer</Product>
3030
<PackageIcon>logo.jpeg</PackageIcon>

Posseth.NamedArguments.AnalyzerAndFixer.Test/NestedInvocationTests.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ public class NestedInvocationTests
1414
[TestMethod]
1515
public async Task NestedInvocations_AreFixed()
1616
{
17-
// Create code with nested method calls
18-
var test = @"
17+
// Configuratie om Info-diagnostieken te negeren
18+
var test = new VerifyCS.Test
19+
{
20+
TestCode = @"
1921
using System;
2022
2123
class TimeProvider
@@ -59,9 +61,8 @@ public Uri GetGetPresignedUrl(string objectKey)
5961
)
6062
);
6163
}
62-
}";
63-
64-
var fixedTest = @"
64+
}",
65+
FixedCode = @"
6566
using System;
6667
6768
class TimeProvider
@@ -104,21 +105,25 @@ public Uri GetGetPresignedUrl(string objectKey)
104105
expires: timeProvider.GetLocalNow().AddHours(value: 24))
105106
);
106107
}
107-
}";
108-
109-
// Expected diagnostics
110-
var expected = new[]
111-
{
112-
// Arguments in the GetGetPresignedUrl method
113-
VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId).WithLocation(39, 17).WithArguments("bucketName"),
114-
VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId).WithLocation(40, 17).WithArguments("objectKey"),
115-
VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId).WithLocation(41, 17).WithArguments("expires"),
116-
117-
// Arguments in the AddHours method
118-
VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId).WithLocation(41, 53).WithArguments("value"),
108+
}",
109+
ExpectedDiagnostics = {
110+
// Arguments in the GetGetPresignedUrl method
111+
VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId).WithLocation(39, 17).WithArguments("bucketName"),
112+
VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId).WithLocation(40, 17).WithArguments("objectKey"),
113+
VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId).WithLocation(41, 17).WithArguments("expires"),
114+
115+
// Arguments in the AddHours method
116+
VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId).WithLocation(41, 53).WithArguments("value"),
117+
},
119118
};
119+
120+
// Negeer Info-diagnostieken
121+
test.TestState.AnalyzerConfigFiles.Add(("/.editorconfig", @"
122+
[*.cs]
123+
dotnet_analyzer_diagnostic.severity = warning
124+
"));
120125

121-
await VerifyCS.VerifyCodeFixAsync(test, expected, fixedTest);
126+
await test.RunAsync();
122127
}
123128
}
124129
}

Posseth.NamedArguments.AnalyzerAndFixer.Test/Posseth.NamedArguments.AnalyzerAndFixer.Test.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
12-
<PackageReference Include="MSTest.TestAdapter" Version="3.8.3" />
13-
<PackageReference Include="MSTest.TestFramework" Version="3.8.3" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
12+
<PackageReference Include="MSTest.TestAdapter" Version="3.9.1" />
13+
<PackageReference Include="MSTest.TestFramework" Version="3.9.1" />
1414
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.14.0" />
1515
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.MSTest" Version="1.1.2" />
1616
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.MSTest" Version="1.1.2" />

Posseth.NamedArguments.AnalyzerAndFixer.Test/PossethNamedArgumentsAnalyzerAndFixerUnitTests.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using Microsoft.CodeAnalysis.Testing;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System.Collections.Generic;
24
using System.Threading.Tasks;
35
using VerifyCS = Posseth.NamedArguments.AnalyzerAndFixer.Test.CSharpCodeFixVerifier<
46
Posseth.NamedArguments.AnalyzerAndFixer.NamedArgumentsAnalyzer,
@@ -298,5 +300,33 @@ void TestMethod(int a, int b)
298300

299301
await VerifyCS.VerifyCodeFixAsync(testCode, expectedDiagnostics, fixedCode);
300302
}
303+
304+
[TestMethod]
305+
public async Task Analyzer_Excludes_FullyQualifiedMethodName_ButNotCustom()
306+
{
307+
var test = @"
308+
using System.Linq;
309+
namespace MyNamespace
310+
{
311+
public class MyClass
312+
{
313+
public void Where(int x) { }
314+
public void Test()
315+
{
316+
var arr = new int[] { 1, 2, 3 };
317+
Where(1); // Custom method, should trigger diagnostic
318+
Enumerable.Where(arr, i => i > 1); // Built-in, should NOT trigger diagnostic
319+
}
320+
}
301321
}
322+
";
323+
324+
// Use the exact location reported in the error message
325+
var expected = VerifyCS.Diagnostic(NamedArgumentsAnalyzer.DiagnosticId)
326+
.WithSpan(11, 23, 11, 24) // This is the exact position of "1" in Where(1)
327+
.WithArguments("x");
328+
329+
await VerifyCS.VerifyAnalyzerAsync(test, expected);
330+
}
331+
}
302332
}

Posseth.NamedArguments.AnalyzerAndFixer/AnalyzerReleases.Unshipped.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55

66
Rule ID | Category | Severity | Notes
77
--------|----------|----------|-------
8-
PNA1000 | Naming | Warning | NamedArgumentsAnalyzer
8+
PNA1000 | Naming | Warning | NamedArgumentsAnalyzer
9+
PNA1000_DefaultMethods | Naming | Info | NamedArgumentsAnalyzer
10+
PNA1000_Info | Naming | Info | NamedArgumentsAnalyzer
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
using System;
2-
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
3-
public sealed class RuleConfigurationOptionAttribute : Attribute
2+
namespace Posseth.NamedArguments.AnalyzerAndFixer
43
{
5-
public string Name { get; }
6-
public string Description { get; }
7-
public string DefaultValue { get; }
8-
9-
public RuleConfigurationOptionAttribute(string name, string description, string defaultValue)
4+
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
5+
public sealed class RuleConfigurationOptionAttribute : Attribute
106
{
11-
Name = name;
12-
Description = description;
13-
DefaultValue = defaultValue;
7+
public string Name { get; }
8+
public string Description { get; }
9+
public string DefaultValue { get; }
10+
11+
public RuleConfigurationOptionAttribute(string name, string description, string defaultValue)
12+
{
13+
Name = name;
14+
Description = description;
15+
DefaultValue = defaultValue;
16+
}
1417
}
1518
}

0 commit comments

Comments
 (0)