Writing a single generic rule for several different types of objects would probably be too confusing, as the TOM does not have, for example, a base type that supports both the Name and the IsHidden property, etc. I guess a "Clone rule" button would be the easiest way to fix this, as well as having an option to logically group several rules as one. Currently, you would have to create a separate rule for every type of object. NET types that should be exposed by default. Let me know if you can think of any other. I found the regex code above on this stackoverflow question. Regex.IsMatch(Name, "(**|**)*") and not IsHidden is one of them, so writing an expression like the following, should return visible objects whose name is in PascalCase: to make it easier to write certain rules.ĭynamic Linq only exposes a predefined set of. Let me know if you feel you need other types of collections, etc. You can try this out by downloading this preview build. (Levels.Any(Column = current)) and not IsHidden.UsedInHierarchies.Any() and not IsHidden.UsedInHierarchies.Count() > 0 and not IsHidden.Which one to use, I guess is a matter of preference: This means that your rule can now be implemented (on Column scope), by either one of these expressions. Table.AllLevels // Iterates all levels across all hierarchies of the tableĬolumn.UsedInHierarchies // Iterates all hierarchies of the table, in which this column is used as a levelĬolumn.UsedInRelationships // Iterates all relationships in which the column is used (either as FromColumn or ToColumn) Model.AllLevels // Iterates all levels across all hierarchies on all tables of the model Model.AllHierarchies // Iterates all hierarchies across all tables of the model Model.AllMeasures // Iterates all measures across all tables of the model Model.AllColumns // Iterates all columns across all tables of the model Let me know if you have any further questions! The next time you run Tabular Editor, you should then see these 4 rules in the BPA (naturally, the bottom grid will only display objects that are in violation of the selected rule, when a model is loaded in Tabular Editor): "Expression": "(FromColumn = outerIt) and not IsHidden and not Table.IsHidden ", "Description": "Columns used on the Many side of a relationship should be hidden. "Expression": "(DataType = \"Int64 \" or DataType = \"Decimal \" or DataType = \"Double \") \nand IsHidden = false \nand (Name.EndsWith( \"Key \") or Name.EndsWith( \"ID \") or Name.EndsWith( \"Code \")) \nand SummarizeBy != \"None \" ", "Description": "Visible numerical columns whose name ends with \"Key \", \"ID \" or \"Code \" should have their \"SummarizeBy \" property set to \"None \" ", "Name": "Do not summarize visible key columns ", "Expression": "Measures.Count(not IsHidden and string.IsNullOrEmpty(DisplayFolder)) > 10 " "Description": "Tables with more than 10 visible measures should have them organized in display folders for improved usability ", "Name": "Organize measures in display folders ", "ID": "ORGANIZE_COLUMNS_IN_DISPLAY_FOLDERS ", "Expression": "String.IsNullOrWhitespace(FormatString) " "Description": "FormatString property should be set for all measures ", "Name": "Apply format string to measures ", "ID": "APPLY_FORMAT_STRING_TO_MEASURES ", Lastly, I'm considering packaging this Best Practice Analyzer as a stand-alone Visual Studio plug-in, that could be used even without Tabular Editor. If you have any other suggestions for standard rules that should ship with Tabular Editor, please let me know - everyone is welcome to suggest! json file on the machine (for standard rules). Behind the scenes, rules are defined using Dynamic LINQ so the expressions generated by the UI are quite easy to understand, and these will be stored directly in the model annotations (for local rules) or in a. I'm currently working on an UI for defining rules (a rule builder - I didn't find any interesting 3rd party libraries compatible with WinForms, so I decided to roll my own.). This is possible for standard rules, where we can define how a rule violation can be fixed - for example, by setting the "Summarize By" property to a different value. Double-clicking an item in the lower list switches focus back to the main form and selects the corresponding object in the tree:Īdditionally, the lower list has a context menu that provides shortcuts to "fix" any violations encountered. Just an FYI - this new feature is coming along great! Screenshot below shows the new interface for browsing defined rules and identifying objects that are in violation.
0 Comments
Leave a Reply. |