public override void Initialize(IPendingCheckin pendingCheckin) { base.Initialize(pendingCheckin); this.pendingCheckin = pendingCheckin; pendingCheckin.WorkItems.CheckedWorkItemsChanged += WorkItems_CheckedWorkItemsChanged; }
public List<BranchPolicyFailure> EvaluatePendingCheckin(IPendingCheckin pendingCheckin) { TellMe.Instance.TrackTrace(string.Format("EvaluatePendingCheckin for {0}", this.Name)); Stopwatch polictTiming = new Stopwatch(); List<BranchPolicyFailure> branchPolicyFailures = new List<BranchPolicyFailure>(); foreach (IBranchPolicy branchPolicy in BranchPolicies) { TellMe.Instance.TrackTrace(string.Format("BEGIN-EvaluatePendingCheckin for {0}", branchPolicy.Name)); try { polictTiming.Restart(); IList<BranchPolicyFailure> bpfs = new List<BranchPolicyFailure>(); bpfs = branchPolicy.EvaluatePendingCheckin(this, pendingCheckin); TellMe.Instance.TrackMetric(string.Format("Policy-{0}-PolicyFailures", branchPolicy.Name), branchPolicyFailures.Count); branchPolicyFailures.AddRange(bpfs); TellMe.Instance.TrackMetric(string.Format("Policy-{0}-Timepan", branchPolicy.Name), polictTiming.ElapsedMilliseconds); } catch (Exception ex) { TellMe.Instance.TrackException(ex); branchPolicyFailures.Add(new BranchPolicyFailure(string.Format("An error occured in policy '{0}' for the BranchPattern '{1}'. Please contact the Build Team providing the session ID {2}:\n\n{3}", branchPolicy.Name, this.Name, TellMe.Instance.Context.Session.Id, ex.ToString()))); } TellMe.Instance.TrackTrace(string.Format("END-EvaluatePendingCheckin for {0}", branchPolicy.Name)); } TellMe.Instance.TrackTrace(string.Format("Returning {0} Policy failures", branchPolicyFailures.Count)); return branchPolicyFailures; }
/// <summary> /// Initializes the policy. /// </summary> /// <param name="pendingCheckin">The <see cref="IPendingCheckin"/> to use during initialization.</param> public override void Initialize(IPendingCheckin pendingCheckin) { if (pendingCheckin == null) { ThrowHelper.ThrowArgumentNullException("pendingCheckin"); } // Get the reference to the VS ide. dte = (DTE)pendingCheckin.GetService(typeof(DTE)); if (taskProvider != null) { // Initialize zo clear the taskprovider. taskProvider.Clear(); } else { if (dte != null && dte.Application != null) { taskProvider = new ViolationTaskProvider( new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)dte.Application), this.Settings); } } base.Initialize(pendingCheckin); }
/// <summary> /// Initializes this policy for the specified pending checkin. /// </summary> /// <param name="pendingCheckin" />The pending checkin.</param> public override void Initialize(IPendingCheckin pendingCheckin) { base.Initialize(pendingCheckin); _pendingCheckin = pendingCheckin; pendingCheckin.PendingChanges.CheckedPendingChangesChanged += PendingChanges_CheckedPendingChangesChanged; }
public List <BranchPolicyFailure> EvaluatePendingCheckin(IPendingCheckin pendingCheckin) { TellMe.Instance.TrackTrace(string.Format("EvaluatePendingCheckin for {0}", this.Name)); Stopwatch polictTiming = new Stopwatch(); List <BranchPolicyFailure> branchPolicyFailures = new List <BranchPolicyFailure>(); foreach (IBranchPolicy branchPolicy in BranchPolicies) { TellMe.Instance.TrackTrace(string.Format("BEGIN-EvaluatePendingCheckin for {0}", branchPolicy.Name)); try { polictTiming.Restart(); IList <BranchPolicyFailure> bpfs = new List <BranchPolicyFailure>(); bpfs = branchPolicy.EvaluatePendingCheckin(this, pendingCheckin); TellMe.Instance.TrackMetric(string.Format("Policy-{0}-PolicyFailures", branchPolicy.Name), branchPolicyFailures.Count); branchPolicyFailures.AddRange(bpfs); TellMe.Instance.TrackMetric(string.Format("Policy-{0}-Timepan", branchPolicy.Name), polictTiming.ElapsedMilliseconds); } catch (Exception ex) { TellMe.Instance.TrackException(ex); branchPolicyFailures.Add(new BranchPolicyFailure(string.Format("An error occured in policy '{0}' for the BranchPattern '{1}'. Please contact the Build Team providing the session ID {2}:\n\n{3}", branchPolicy.Name, this.Name, TellMe.Instance.Context.Session.Id, ex.ToString()))); } TellMe.Instance.TrackTrace(string.Format("END-EvaluatePendingCheckin for {0}", branchPolicy.Name)); } TellMe.Instance.TrackTrace(string.Format("Returning {0} Policy failures", branchPolicyFailures.Count)); return(branchPolicyFailures); }
/// <summary> /// Gets all <see cref="PendingChange"/> instances for "*.csproj" files. /// </summary> private static IEnumerable <PendingChange> GetCheckedPendingProjects(IPendingCheckin pendingCheckin) { foreach (PendingChange pendingChange in pendingCheckin.PendingChanges.CheckedPendingChanges) { string projectFileName = pendingChange.FileName; if (projectFileName.EndsWith(".csproj")) { yield return(pendingChange); } } }
/// <summary> /// Initializes this policy for the specified pending checkin. /// </summary> /// <param name="pendingCheckin" />The pending checkin.</param> public override void Initialize(IPendingCheckin pendingCheckin) { try { base.Initialize(pendingCheckin); } catch (Exception ex) { TellMe.Instance.TrackException(ex); throw ex; } base.InstallationInstructions = "Download policy from http://somewhere"; }
public void SetCheckinComment(IPendingCheckin pendingCheckin, IEnumerable<PendingChange> pendingChanges) { if (pendingCheckin == null) { return; } if (!string.IsNullOrWhiteSpace(pendingCheckin.PendingChanges.Comment)) { return; } pendingCheckin.PendingChanges.Comment = this.GetCommentText(pendingChanges); }
/// <summary> /// Initializes this policy for the specified pending checkin. /// </summary> /// <param name="pendingCheckin" />The pending checkin.</param> public override void Initialize(IPendingCheckin pendingCheckin) { try { base.Initialize(pendingCheckin); _pendingCheckin = pendingCheckin; TellMe.Instance.Context.Properties["PolicyType"] = this.Type; if (pendingCheckin != null) { pendingCheckin.PendingChanges.CheckedPendingChangesChanged += PendingChanges_CheckedPendingChangesChanged; } } catch (Exception ex) { TellMe.Instance.TrackException(ex); throw ex; } }
public override void Initialize(IPendingCheckin pendingCheckin) { base.Initialize(pendingCheckin); _affectedTeamProjectsEventHandler = (sender, e) => { warningDismissed = false; OnPolicyStateChanged(Evaluate()); }; _checkedPendingChangesEventHandler = (sender, e) => { warningDismissed = false; OnPolicyStateChanged(Evaluate()); }; pendingCheckin.PendingChanges.AffectedTeamProjectsChanged += _affectedTeamProjectsEventHandler; pendingCheckin.PendingChanges.CheckedPendingChangesChanged += _checkedPendingChangesEventHandler; }
public override void Initialize(IPendingCheckin pendingCheckin) { if (this._taskProvider != null) { this._taskProvider.Clear(); } else { _DTE dte = (_DTE)pendingCheckin.GetService(typeof(_DTE)); if (dte != null && dte.Application != null) { this._taskProvider = new ViolationTaskProvider(new ServiceProvider((IServiceProvider)dte.Application)); } } base.Initialize(pendingCheckin); }
// [rgn] Public Methods (1) public static PolicyFailure[] Evaluate(IPendingCheckin pendingCheckin, IPolicyEvaluation policyEvaluation) { List <PolicyFailure> failures = new List <PolicyFailure>(); // Iterate over all changes to files that end with ".csproj". foreach (PendingChange pendingChange in GetCheckedPendingProjects(pendingCheckin)) { // Examine the csproj file and validate all constraints. // Start by reading the csproj into an XmlDocument. XmlDocument csprojDocument = new XmlDocument(); csprojDocument.Load(pendingChange.LocalItem); // Iterate over all of this project's build configurations. foreach (XmlNode node in GetBuildConfigurationNodes(csprojDocument)) { // Get the build configuration's name. string configurationName = node.Attributes["Condition"].InnerText; // Get the build configuration's debug symbol type. string debugType = node["DebugType"].InnerText; // Check if any constraint is unsatisfied with this build configuration. foreach (DebugSymbolConstraint unsatisfiedConstraint in GetUnsatisfiedConstraints(configurationName, debugType)) { // A constraint is unsatisfied with this project's build configuration. Report a failure. string message = string.Format("Project '{0}' does not satisfy the constraint '{1}'.", pendingChange.FileName, unsatisfiedConstraint); PolicyFailure failure = new PolicyFailure(message, policyEvaluation); failures.Add(failure); } } } return(failures.ToArray()); }
public CheckinAnalyzer(IPendingCheckin pendingCheckin, ITypeLocator typeLocator) { _pendingCheckin = pendingCheckin; _typeLocator = typeLocator; }
public CheckinAnalyzer(IPendingCheckin pendingCheckin) : this(pendingCheckin, new TypeLocator()) { }
/// <summary> /// Initializes a new instance of the <see cref="RalphJansen.StyleCopCheckInPolicy.Policy.EvaluationContext"/> class. /// </summary> /// <param name="policy">The policy instance.</param> /// <param name="settings">The policy settings.</param> /// <param name="pendingCheckin">The pending check-in whose files to analyze.</param> public EvaluationContext(IPolicyEvaluation policy, PolicySettings settings, IPendingCheckin pendingCheckin) { this.Policy = policy; this.Settings = settings; this.PendingCheckin = pendingCheckin; }