Skip to content

Commit

Permalink
S4275: add repro for #8101
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioaversa committed Sep 28, 2023
1 parent 77f835f commit 68bd2db
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,37 @@ public class PropertiesAccessCorrectFieldTest

[TestMethod]
public void PropertiesAccessCorrectField_CS() =>
builderCS.AddPaths(@"PropertiesAccessCorrectField.cs").AddReferences(AdditionalReferences).Verify();
builderCS.AddPaths("PropertiesAccessCorrectField.cs").AddReferences(AdditionalReferences).Verify();

[TestMethod]
public void PropertiesAccessCorrectField_CSharp8() =>
builderCS.AddPaths(@"PropertiesAccessCorrectField.CSharp8.cs").WithOptions(ParseOptionsHelper.FromCSharp8).Verify();
builderCS.AddPaths("PropertiesAccessCorrectField.CSharp8.cs").WithOptions(ParseOptionsHelper.FromCSharp8).Verify();

#if NET

[TestMethod]
public void PropertiesAccessCorrectField_CSharp9() =>
builderCS.AddPaths(@"PropertiesAccessCorrectField.CSharp9.cs").WithOptions(ParseOptionsHelper.FromCSharp9).Verify();
builderCS.AddPaths("PropertiesAccessCorrectField.CSharp9.cs").WithOptions(ParseOptionsHelper.FromCSharp9).Verify();

[TestMethod]
public void PropertiesAccessCorrectField_CSharp12() =>
builderCS.AddPaths("PropertiesAccessCorrectField.CSharp12.cs").WithOptions(ParseOptionsHelper.FromCSharp12).Verify();

#else

[TestMethod]
public void PropertiesAccessCorrectField_CS_NetFramework() =>
builderCS.AddPaths(@"PropertiesAccessCorrectField.NetFramework.cs").AddReferences(AdditionalReferences).Verify();
builderCS.AddPaths("PropertiesAccessCorrectField.NetFramework.cs").AddReferences(AdditionalReferences).Verify();

[TestMethod]
public void PropertiesAccessCorrectField_VB_NetFramework() =>
builderVB.AddPaths(@"PropertiesAccessCorrectField.NetFramework.vb").AddReferences(AdditionalReferences).Verify();
builderVB.AddPaths("PropertiesAccessCorrectField.NetFramework.vb").AddReferences(AdditionalReferences).Verify();

#endif

[TestMethod]
public void PropertiesAccessCorrectField_VB() =>
builderVB.AddPaths(@"PropertiesAccessCorrectField.vb").AddReferences(AdditionalReferences).Verify();
builderVB.AddPaths("PropertiesAccessCorrectField.vb").AddReferences(AdditionalReferences).Verify();

private static IEnumerable<MetadataReference> AdditionalReferences =>
NuGetMetadataReference.MvvmLightLibs("5.4.1.1")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://github.com/SonarSource/sonar-dotnet/issues/8101
namespace Repro_8101
{
public class SomeClass(object y)
{
object x;

public object Y
{
get { return x; } // FN
set { x ??= value; } // FN
}
}
}

0 comments on commit 68bd2db

Please sign in to comment.