cel-go icon indicating copy to clipboard operation
cel-go copied to clipboard

Support for setting protobuf extension fields by name

Open jnthntatum opened this issue 1 year ago • 0 comments

PR #1002 adds syntax for specifying extension fields for select operations, but at the moment the type check and runtime steps don't consider extensions for message creation.

Feature request checklist

  • [X] There are no issues that match the desired change
  • [X] The change is large enough it can't be addressed with a simple Pull Request

Change

Add support for setting extension fields by fully qualified name in protobuf message struct creation. I suspect this isn't a major change, but will address separately from the parser changes to support the syntax.

Example

// Creates a new struct with the extension set:
ExampleType{
    `google.expr.proto2.test.int32_ext`: 42,
    field: "foo"
}.`google.expr.proto2.test.int32_ext` == 42

Alternatives considered

This could be implemented by macro, e.g.

proto.WithExtensionsSet(
   Example{field: "foo"},
  {"google.expr.proto2.test.int32_ext": 42}
).`google.expr.proto2.test.int32_ext` == 42

but dedicated syntax is a bit more clear and in either case there needs to be some update to type check and evaluation to fully support.

jnthntatum avatar Dec 13 '24 18:12 jnthntatum