-
Notifications
You must be signed in to change notification settings - Fork 223
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
Fix Razor location UTs #9242
Fix Razor location UTs #9242
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
| ||
<p>The solution to all problems is: @(RaiseHere(21))</p> | ||
@* ^^^^^^^^^ *@ | ||
@* ^^ Secondary@-1 *@ | ||
|
||
@code | ||
{ | ||
private int magicNumber = RaiseHere(42); | ||
// ^^^^^^^^^ | ||
// ^^ Secondary@-1 | ||
private static int RaiseHere(int nb) | ||
{ | ||
return nb; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,5 @@ | |
|
||
@functions | ||
{ | ||
private static int RaiseHere() => 42; | ||
private static int RaiseHere() { return 42; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,5 @@ | |
|
||
@code | ||
{ | ||
private static int RaiseHere() => 42; | ||
private static int RaiseHere() { return 42; } | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename to |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<p>Explicit expression: @(RaiseHere())</p> @* Noncompliant *@ | ||
@* ^^^^^^^^^ *@ | ||
|
||
<p>Implicit expression: @RaiseHere()</p> @* Noncompliant *@ | ||
@* ^^^^^^^^^ *@ | ||
|
||
<p>Multi-statement block: @{ var result = RaiseHere(); }</p> | ||
@* ^^^^^^^^^ *@ | ||
|
||
<p>Control structures: @if(RaiseHere() == 42) { <text>42</text> }</p> | ||
@* ^^^^^^^^^ *@ | ||
|
||
<p>Loops: @for(var i = 0; i < RaiseHere(); i++) { <text>@i</text> }</p> | ||
@* ^^^^^^^^^ *@ | ||
|
||
<p>Code blocks: @{ RaiseHere(); }</p> | ||
@* ^^^^^^^^^ *@ | ||
|
||
<p>Lambda expression: @((Func<int>)(() => RaiseHere()))()</p> @* Noncompliant *@ | ||
@* ^^^^^^^^^ *@ | ||
|
||
<p>Nested multi-statement block: @{ var result2 = RaiseHere(); var result3 = RaiseHere(); }</p> | ||
@* ^^^^^^^^^ *@ | ||
@* ^^^^^^^^^@-1 *@ | ||
|
||
<p>Nested control structures: @if(RaiseHere() == 42) { <text>@(RaiseHere() + 1)</text> }</p> | ||
@* ^^^^^^^^^ *@ | ||
@* ^^^^^^^^^@-1 *@ | ||
|
||
@code | ||
{ | ||
private static int RaiseHere() { return 42; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,9 +159,23 @@ public class Sample | |
[DataRow("Dummy.SecondaryLocation.cshtml")] | ||
public void Verify_RazorWithAdditionalLocation(string path) => | ||
DummyWithLocation.AddPaths(path) | ||
.WithOptions(ParseOptionsHelper.BeforeCSharp10) | ||
.WithAdditionalFilePath(AnalysisScaffolding.CreateSonarProjectConfig(TestContext, ProjectType.Product)) | ||
.Verify(); | ||
|
||
#if NET | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this required to not fail in the pipeline? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, all razor tests are already within a #if NET directive, so we can remove them |
||
|
||
[DataTestMethod] | ||
[DataRow("Dummy.SecondaryLocation_CSharp10.razor")] | ||
[DataRow("Dummy.SecondaryLocation.cshtml")] | ||
public void Verify_RazorWithAdditionalLocation_CSharp10(string path) => | ||
DummyWithLocation.AddPaths(path) | ||
.WithOptions(ParseOptionsHelper.FromCSharp10) | ||
.WithAdditionalFilePath(AnalysisScaffolding.CreateSonarProjectConfig(TestContext, ProjectType.Product)) | ||
.Verify(); | ||
|
||
#endif | ||
|
||
[TestMethod] | ||
[DataRow("Dummy.razor")] | ||
[DataRow("Dummy.cshtml")] | ||
|
@@ -176,9 +190,24 @@ public class Sample | |
public void Verify_RazorExpressions_Locations(string path) => | ||
DummyWithLocation | ||
.AddPaths(path) | ||
.WithOptions(ParseOptionsHelper.BeforeCSharp10) | ||
.WithAdditionalFilePath(AnalysisScaffolding.CreateSonarProjectConfig(TestContext, ProjectType.Product)) | ||
.Verify(); | ||
|
||
#if NET | ||
|
||
[TestMethod] | ||
[DataRow("DummyExpressions_CSharp10.razor")] | ||
[DataRow("DummyExpressions.cshtml")] | ||
public void Verify_RazorExpressions_Locations_CSharp10(string path) => | ||
DummyWithLocation | ||
.AddPaths(path) | ||
.WithOptions(ParseOptionsHelper.FromCSharp10) | ||
.WithAdditionalFilePath(AnalysisScaffolding.CreateSonarProjectConfig(TestContext, ProjectType.Product)) | ||
.Verify(); | ||
|
||
#endif | ||
|
||
[DataTestMethod] | ||
[DataRow("Dummy.razor")] | ||
[DataRow("Dummy.cshtml")] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file should be called
Dummy.SecondaryLocation.CSharp10.razor
to follow our naming scheme.