-
Notifications
You must be signed in to change notification settings - Fork 237
Closed
Labels
False PositiveRule IS triggered when it shouldn't be.Rule IS triggered when it shouldn't be.
Milestone
Description
Description
When class has StructLayout, we need all its props for memory allocation.
Repro steps
For example
public class Foo {
public void Bar(){
var netResource = new NetResource
{
Scope = ResourceScope.GlobalNetwork,
ResourceType = ResourceType.Disk,
DisplayType = ResourceDisplaytype.Share,
RemoteName = "foo"
};
_ = WNetAddConnection2(netResource, "pass", "user", 0);
}
[DllImport("mpr.dll")]
private static extern int WNetAddConnection2(NetResource netResource, string password, string username, int flags);
[StructLayout(LayoutKind.Sequential)]
private struct NetResource
{
public ResourceScope Scope;
public ResourceType ResourceType;
public ResourceDisplaytype DisplayType;
public int Usage;
public string LocalName;
public string RemoteName;
public string Comment;
public string Provider;
}
}
Expected behavior
no issue
Actual behavior
S1144 on not used props of NetResource struct
Related information
SonarAnalyzer.CSharp 8.54.0.64047
Metadata
Metadata
Assignees
Labels
False PositiveRule IS triggered when it shouldn't be.Rule IS triggered when it shouldn't be.