internal static int GetEvaluationId(BuildEventContext buildEventContext) { if (buildEventContext == null) { return -1; } if (buildEventContext is BuildEventContextWithEvaluationId withEvaluationId) { return withEvaluationId.EvaluationId; } if (EvaluationIdGetter == null) { var type = buildEventContext.GetType(); var field = type.GetField("_evaluationId", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { EvaluationIdGetter = b => (int)field.GetValue(b); } else { EvaluationIdGetter = b => b.ProjectContextId <= 0 ? -b.ProjectContextId : -1; } } return EvaluationIdGetter(buildEventContext); }
internal static int GetEvaluationId(BuildEventContext buildEventContext) { if (EvaluationIdGetter == null) { var type = buildEventContext.GetType(); var field = type.GetField("_evaluationId", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { EvaluationIdGetter = b => (int)field.GetValue(b); } else { EvaluationIdGetter = b => buildEventContext.ProjectContextId < 0 ? buildEventContext.ProjectContextId : int.MinValue; } } return(EvaluationIdGetter(buildEventContext)); }
internal static int GetEvaluationId(BuildEventContext buildEventContext) { if (buildEventContext == null) { return(-1); } if (evaluationIdGetter == null) { Type type = buildEventContext.GetType(); FieldInfo field = type.GetField("_evaluationId" /*, BindingFlags.Instance | BindingFlags.NonPublic*/); if (field != null) { evaluationIdGetter = b => (int)field.GetValue(b); } else { evaluationIdGetter = b => b.ProjectContextId <= 0 ? -b.ProjectContextId : -1; } } return(evaluationIdGetter(buildEventContext)); }