/// <summary> /// Causes the collection identified by <paramref name="expression"/> to be compared in the order /// in which the items appear in the expectation. /// </summary> public EquivalencyAssertionOptions <TExpectation> WithStrictOrderingFor( Expression <Func <TExpectation, object> > expression) { string expressionMemberPath = expression.GetMemberPath().ToString(); OrderingRules.Add(new PathBasedOrderingRule(expressionMemberPath)); return(this); }
/// <summary> /// The execute transaction inner. /// </summary> /// <param name="solution"> /// The solution. /// </param> /// <param name="textControl"> /// The text control. /// </param> public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl) { ITreeNode element = Utils.GetElementAtCaret(solution, textControl); IAccessorOwnerDeclaration declaration = element.GetContainingNode <IAccessorOwnerDeclaration>(true); if (declaration != null) { OrderingRules.CheckAccessorOrder(declaration); } }
/// <summary> /// The execute transaction inner. /// </summary> /// <param name="solution"> /// The solution. /// </param> /// <param name="textControl"> /// The text control. /// </param> public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl) { ICSharpFile file = Utils.GetCSharpFile(solution, textControl); Lifetimes.Using( lifetime => { StyleCopApi api = solution.GetComponent <StyleCopApiPool>().GetInstance(lifetime); Settings settings = api.Settings.GetSettings(file.GetSourceFile().ToProjectFile()); // Fixes SA1208, SA1209, SA1210, SA1211 OrderingRules.ExecuteAll(file, settings); }); }
public void OrderEnumerableByTwoFields() { var rules = new OrderingRules <Columns, Entity> { { Columns.Id, entity => entity.Id }, { Columns.Name, entity => entity.Name }, }; var entities = new[] { new Entity { Id = 1, Name = "a" }, new Entity { Id = 2, Name = "a" }, new Entity { Id = 1, Name = "b" }, }; var actual = entities.AsEnumerable().OrderBy(rules, Columns.Id, false).ThenBy(rules, Columns.Name, true); var expected = new[] { new Entity { Id = 1, Name = "b" }, new Entity { Id = 1, Name = "a" }, new Entity { Id = 2, Name = "a" }, }; Assert.That(actual, Is.EquivalentTo(expected)); }
/// <summary> /// Processes all the cleanup. /// </summary> /// <param name="projectFile"> /// The project file to clean. /// </param> /// <param name="file"> /// The PSI file to clean. /// </param> /// <param name="fixXmlDocViolations"> /// Flag to indicate if XML doc stubs should be created /// </param> private void InternalProcess(IProjectFile projectFile, ICSharpFile file, bool fixXmlDocViolations) { // Process the file for all the different Code Cleanups we have here // we do them in a very specific order. Do not change it. Lifetimes.Using( lifetime => { StyleCopApiPool apiPool = projectFile.GetSolution().GetComponent <StyleCopApiPool>(); Settings settings = apiPool.GetInstance(lifetime).Settings.GetSettings(projectFile); ReadabilityRules.ExecuteAll(file, settings); MaintainabilityRules.ExecuteAll(file, settings); if (fixXmlDocViolations) { DocumentationRules.ExecuteAll(file, settings); } LayoutRules.ExecuteAll(file, settings); SpacingRules.ExecuteAll(file, settings); OrderingRules.ExecuteAll(file, settings); }); }