Skip to content
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

Exposing ResultLevelKind #2331

Merged
merged 2 commits into from
Apr 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/Sarif/Core/ResultLevelKind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.CodeAnalysis.Sarif
{
public class ResultLevelKind
{
private ResultKind? resultKind;

public ResultKind Kind
{
get
{
// If kind is absent, it SHALL default to "fail".
if (!resultKind.HasValue)
{
return ResultKind.Fail;
}

// If level has any value other than "none" and kind is present, then kind SHALL have the value "fail".
if (Level != FailureLevel.None)
{
return ResultKind.Fail;
}

return resultKind.Value;
}
set { resultKind = value; }
Copy link
Member

@michaelcfanning michaelcfanning Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resultKind = value

If someone sets a kind that isn't 'Fail', you should clear Level. Right? #Closed

}

public FailureLevel Level { get; set; }
Copy link
Member

@michaelcfanning michaelcfanning Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set

If someone sets this value to non-zero, you should slam 'Fail' into the Kind property or perhaps just set it to null so that the default gets picked up in its setter. #Closed

}
}