Skip to content

Define the rule and policy contexts for inline code #61

Description

@woksin

Inline and file-referenced code is meant to be a sandbox: for C# we do not expect a namespace or a class, just the method body, and usually not even the signature — because a predictable context is in scope. The context differs for a command, a query, a rule and a policy.

Two of those four do not exist.

Today

The whole of Contexts/ is:

  • Causation.cs
  • CausedBy.cs
  • CommandContext.cs
  • QueryContext.cs
  • TenantId.cs

So:

  • Command context — defined (Contexts/CommandContext.cs:21-26), documented.
  • Query context — defined (Contexts/QueryContext.cs:22-27), documented.
  • Rule context — does not exist. ValidationRuleKind.Rule (Syntax/CommandSyntax.cs:76) accepts a file reference or an inline csharp block, and validate csharp accepts a block, with no declared contract for either.
  • Policy context — does not exist. PolicySyntax.Code (Syntax/PolicySyntax.cs:34) accepts an inline block against nothing.

The two that do exist are also the same shape rather than differentiated, and $context.identity is accepted by the expression parser (Syntax/Expressions.cs:43-44) and documented, while appearing on neither record.

Why this blocks more than it looks

Autocompletion for the inline languages has to limit itself to the scope the inline method actually has. That scope is the context. So inline-language autocompletion cannot be built for rules or policies at all until this lands — the work is strictly downstream of it.

A policy context in particular needs claims and roles; CausedBy today exposes only subject, name and userName.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions