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

Rename the 'guid' property to 'logId'. #2037

Merged
merged 1 commit into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 11 additions & 11 deletions src/Sarif.WorkItems/SarifWorkItemFiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public virtual SarifLog FileWorkItems(SarifLog sarifLog)
{
using (Logger.BeginScopeContext(nameof(FileWorkItems)))
{

sarifLog = sarifLog ?? throw new ArgumentNullException(nameof(sarifLog));
sarifLog.SetProperty(LOGID_PROPERTY_NAME, Guid.NewGuid());

IReadOnlyList<SarifLog> logsToProcess = SplitLogFile(sarifLog);

Expand Down Expand Up @@ -146,7 +146,6 @@ public virtual IReadOnlyList<SarifLog> SplitLogFile(SarifLog sarifLog)
using (Logger.BeginScopeContext(nameof(SplitLogFile)))
{
sarifLog = sarifLog ?? throw new ArgumentNullException(nameof(sarifLog));
sarifLog.SetProperty("guid", Guid.NewGuid());

this.FilingResult = FilingResult.None;
this.FiledWorkItems = new List<WorkItemModel>();
Expand Down Expand Up @@ -245,13 +244,11 @@ public virtual IReadOnlyList<SarifLog> SplitLogFile(SarifLog sarifLog)
return logsToProcess.ToArray();
}

internal const string PROGRAMMABLE_URIS_PROPERTY_NAME = "programmableWorkItemUris";

public SarifWorkItemModel FileWorkItemInternal(SarifLog sarifLog, SarifWorkItemContext filingContext, FilingClient filingClient)
{
using (Logger.BeginScopeContext(nameof(FileWorkItemInternal)))
{
string logGuid = sarifLog.GetProperty<Guid>("guid").ToString();
string logId = sarifLog.GetProperty<Guid>(LOGID_PROPERTY_NAME).ToString();

// The helper below will initialize the sarif work item model with a copy
// of the root pipeline filing context. This context will then be initialized
Expand Down Expand Up @@ -303,7 +300,7 @@ public SarifWorkItemModel FileWorkItemInternal(SarifLog sarifLog, SarifWorkItemC
}
catch (Exception ex)
{
this.Logger.LogError(ex, "An exception was raised filing log '{logGuid}'.", logGuid);
this.Logger.LogError(ex, "An exception was raised filing log '{logId}'.", logId);

Dictionary<string, object> customDimentions = new Dictionary<string, object>();
customDimentions.Add("ExceptionType", ex.GetType().FullName);
Expand Down Expand Up @@ -343,16 +340,16 @@ private void LogMetricsForProcessedModel(SarifLog sarifLog, SarifWorkItemModel s

this.FilingResult = filingResult;

string logGuid = sarifLog.GetProperty<Guid>("guid").ToString();
string logId = sarifLog.GetProperty<Guid>(LOGID_PROPERTY_NAME).ToString();
string tags = string.Join(",", sarifWorkItemModel.LabelsOrTags);
string uris = sarifWorkItemModel.LocationUris?.Count > 0
? string.Join(",", sarifWorkItemModel.LocationUris)
: "";

var workItemMetrics = new Dictionary<string, object>
{
{ "LogGuid", logGuid },
{ "WorkItemModelGuid", sarifWorkItemModel.Guid },
{ "LogId", logId },
{ "WorkItemModelId", sarifWorkItemModel.Id },
{ nameof(sarifWorkItemModel.Area), sarifWorkItemModel.Area },
{ nameof(sarifWorkItemModel.BodyOrDescription), sarifWorkItemModel.BodyOrDescription },
{ "FilingResult", filingResult.ToString() },
Expand Down Expand Up @@ -397,8 +394,8 @@ private void LogMetricsForProcessedModel(SarifLog sarifLog, SarifWorkItemModel s

var workItemDetailMetrics = new Dictionary<string, object>
{
{ "LogGuid", logGuid },
{ "WorkItemModelGuid", sarifWorkItemModel.Guid },
{ "LogId", logId },
{ "WorkItemModelId", sarifWorkItemModel.Id },
{ nameof(ruleMetrics.Tool), ruleMetrics.Tool },
{ nameof(ruleMetrics.RuleId), ruleMetrics.RuleId },
{ nameof(ruleMetrics.ErrorCount), ruleMetrics.ErrorCount },
Expand Down Expand Up @@ -509,5 +506,8 @@ public void Dispose()
channel?.Flush();
channel?.Dispose();
}

internal const string PROGRAMMABLE_URIS_PROPERTY_NAME = "programmableWorkItemUris";
internal const string LOGID_PROPERTY_NAME = "logId";
}
}
4 changes: 2 additions & 2 deletions src/Sarif.WorkItems/SarifWorkItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public class SarifWorkItemModel : WorkItemModel<SarifWorkItemContext>

// The sarifLog parameter contains exactly a set of results that are intended to be filed as a single work item
// and this log will be attached to the work item.
public SarifWorkItemModel(SarifLog sarifLog, SarifWorkItemContext context = null, Guid guid = default(Guid))
public SarifWorkItemModel(SarifLog sarifLog, SarifWorkItemContext context = null, Guid id = default(Guid))
{
if (sarifLog == null) { throw new ArgumentNullException(nameof(sarifLog)); }

this.SarifLog = sarifLog;
this.Context = context ?? new SarifWorkItemContext();

this.Guid = (guid == default(Guid)) ? Guid.NewGuid() : guid;
this.Id = (id == default(Guid)) ? Guid.NewGuid() : id;

var visitor = new ExtractAllArtifactLocationsVisitor();
visitor.VisitSarifLog(sarifLog);
Expand Down
2 changes: 1 addition & 1 deletion src/WorkItems/WorkItemModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class WorkItemModel
// TODO: Provide a meaningful representation of work item state in the model.
// https://github.com/microsoft/sarif-sdk/issues/1758

public Guid Guid { get; set; }
public Guid Id { get; set; }

public string OwnerOrAccount { get; set; }

Expand Down