Library / SDK
microsoft/OAT avatar
microsoft/OAT

OAT: A Rules Engine for Arbitrary C# Objects

Object Analysis Toolkit is a C# library for analyzing objects using Rules.

102 stars19 forksC#MIT

At a glance

What is it?
Microsoft's Object Analysis Toolkit applies rule-based logic to any C# object, with extensible operations and captures. It is a library for developers who want declarative analysis without writing custom traversal code.
Who is it for?
Adopt OAT if you need a rule-based analysis layer over arbitrary C# objects and want to avoid writing bespoke traversal and evaluation code. It fits scenarios like validation, scanning, or policy checks where rules must be defined separately from the code.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 3 days ago.
What is it written in?
Mainly C#, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • microsoft/OAT102 ★ · +2
Star history
Repository2026-08-182026-11-15
microsoft/OAT100102

2 Stars in the last 89 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

What OAT Solves and Who It Is For

OAT addresses a recurring problem in C# applications: how to apply a set of declarative rules to an object without hard-coding each check. Instead of writing if-else chains or reflection-heavy visitor patterns, you define rules that target fields and properties of any object. The README describes it as a "rules driven metaprogramming engine for arbitrary C# objects." That means the object does not need to implement a special interface or inherit from a base class. The library is aimed at engineers who need to evaluate conditions against object graphs, such as in security scanners, configuration validators, or data quality tools. It is also useful when rules must be authored or changed without recompiling the host application, since rules are data structures that can be serialized or built at runtime.

The Rule and Clause Mechanism

The core unit is a Rule, which contains a target object, an integer severity, a boolean expression, and a list of Clauses. Each Clause applies a specified Operation to a Field of the target. The field can be any property, subproperty, or field of the object, for example "SomeFieldOfTarget.SomeObject.SomeProperty." This dotted path is what gives OAT its reach: you can drill into nested objects without writing explicit navigation code. The boolean expression on the Rule combines the results of the clauses, so you can express logic like "clause A and clause B" or "clause A or not clause B." The actual syntax of that expression is not detailed in the README, but the wiki covers rule authoring. The key point is that the engine evaluates each clause against the target and then applies the expression to decide if the rule matches.

Extensibility Through Delegates

OAT does not try to cover every possible comparison or data type out of the box. Instead, it allows expansion in two directions. First, the set of Operations can be extended with delegates, so you can define custom operations beyond the built-in ones. Second, the object types supported by existing operations can also be expanded with delegates. This is important because C# objects can contain types like DateTime, custom classes, or collections that a generic engine might not know how to compare. The README points to a wiki page on delegates for implementation details. This design keeps the core library small and gives adopters a clear path when they hit a type or operation that is not handled. The trade-off is that you must write and maintain those delegates yourself, which adds work if your object model is diverse.

Getting Started: Commands and API

You obtain OAT as a NuGet package named Microsoft.CST.OAT. If you want to use C# scripts inside rules, you also need the companion package Microsoft.CST.OAT.Scripting. The README shows a minimal usage example: create an Analyzer instance, then call Analyze with a collection of rules and a target object. That returns the rules that apply. For capturing clause results, you call GetCaptures instead. The example is brief but shows the two main entry points. The wiki has a full walkthrough that includes creating a custom operation and validating rules, so the README is not the complete guide. There is also an experimental Blazor app, OAT Blazor, that runs in the browser and lets you author rules and test them against objects from an assembly you provide. That is a useful way to experiment without writing a console app first.

Limitations and Failure Modes

The most obvious limitation is that OAT is not a standalone application; it is a library, so you must integrate it into your own code. There is no CLI or service included. The README does not mention any performance characteristics, so for very large object graphs or high-throughput scenarios you need to benchmark it yourself. Another gap is that the boolean expression syntax is not documented in the README, so you must consult the wiki to learn it. If you rely on C# scripting, that requires an additional package and likely brings the overhead of the scripting runtime. A case where OAT is the wrong tool is when your analysis needs to mutate objects or maintain state across rules; the API appears read-only, returning matches or captures, not modifying the target. For such needs, a full rules engine like NRules or a custom visitor would be more appropriate.

Alternatives and Differences

The closest alternative in the .NET ecosystem is NRules, a production rule engine that implements the Rete algorithm and supports forward chaining. NRules works with facts and rules that fire actions, which is a different model from OAT's clause-based matching. OAT is lighter: it evaluates a set of rules against a single target and returns which rules apply. NRules is designed for complex event processing and inference, where rules can trigger other rules. Another alternative is writing plain C# predicates, but that loses the declarative, data-driven aspect that OAT offers. If you only need simple field checks, a lambda expression might be simpler, but OAT gives you a uniform representation that can be serialized or built dynamically. The choice depends on whether you need rule chaining and actions (NRules) or a straightforward match-and-capture model (OAT).

Maintenance and Licensing

OAT is licensed under the MIT License, so you can use it in commercial projects with minimal restrictions. The repository is not archived, but the README does not show recent releases or a last push date, so you should check the NuGet page for the latest version and release history. The project is part of Microsoft's open source ecosystem, which usually means active maintenance, but that is not guaranteed. The README mentions a Contributor License Agreement for contributions, which is standard for Microsoft projects. For adoption, the maintenance cost is low if you stick to built-in operations, but it rises if you need custom delegates, because you must test those against new object types. The wiki is the main documentation, and it appears to be the source of truth for advanced usage. Before relying on OAT in production, read the walkthrough and delegate pages, and verify that the scripting package is maintained if you need it.

Editorial conclusion

Adopt OAT if you need a rule-based analysis layer over arbitrary C# objects and want to avoid writing bespoke traversal and evaluation code. It fits scenarios like validation, scanning, or policy checks where rules must be defined separately from the code. Skip it if your analysis requires complex stateful logic or heavy use of external data sources, since OAT is primarily about matching and capturing. Before adopting, verify that the built-in operations cover your field types, and plan for custom delegates if they do not. Check the wiki for the full walkthrough and delegate documentation, and confirm the current NuGet version because the repository shows no recent releases.

Frequently asked questions

What is the Object Analysis Toolkit used for?

OAT is a rules driven metaprogramming engine for arbitrary C# objects. You define rules that carry a target, an int severity, a boolean expression, and a list of clauses, then run them against objects with the Analyzer.

Which NuGet package do I need to use OAT?

The library is Microsoft.CST.OAT. To enable using C# scripts in rules you also need Microsoft.CST.OAT.Scripting as a separate package.

What is the difference between Analyze and GetCaptures in OAT?

Analyze returns the rules which applied to the target. GetCaptures returns the results that clauses captured while performing their operations, which are returned with the applied rule.

Can I add my own operation or object type to OAT?

Yes. The operation set can be expanded with delegates, and the object types supported by existing operations can also be expanded with delegates. Implementation details for each delegate are on the Delegates page of the wiki.

Can I try OAT rules in a browser without installing anything?

OAT Blazor is an experimental WebAssembly app that runs in your browser, letting you author rules and test them in a Sandbox using objects instantiated from an assembly you provide.

Official sources

  1. Official README
  2. Project repository
  3. README
  4. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/microsoft-oat.svg)](https://hysenlabs.com/projects/microsoft-oat)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/microsoft-oat.svg)](https://hysenlabs.com/projects/microsoft-oat)

Was this useful?