forked from SonarSource/sonar-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add C# 9 unit tests for S4055 (SonarSource#3752)
- Loading branch information
1 parent
5e72b07
commit c285b29
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...onarAnalyzer.UnitTest/TestCases/LiteralsShouldNotBePassedAsLocalizedParameters.CSharp9.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.ComponentModel; | ||
|
||
TopLevelLocalFunction("literal", "literal"); //Noncompliant | ||
//Noncompliant@-1 | ||
|
||
void TopLevelLocalFunction([Localizable(true)] string param1, string message) | ||
{ | ||
} | ||
|
||
record Record | ||
{ | ||
[Localizable(true)] | ||
public string Property1 { get; set; } | ||
public string Property2 { get; set; } | ||
|
||
public void Method() | ||
{ | ||
Property1 = "lorem"; // Noncompliant | ||
Property2 = "ipsum"; | ||
|
||
LocalFunctionWithAttribute("literal"); //Noncompliant | ||
|
||
void LocalFunctionWithAttribute([Localizable(true)] string param1) | ||
{ | ||
} | ||
} | ||
} |