Skip to content

Map primitive C++ constants to C# constants #674

@ddobrev

Description

@ddobrev

We use dynamic calls in C# to resolve symbols for C++ constants. This has the following three problems:

  1. It's much slower than reading a hard-coded value;
  2. It prevents constants from being used in default values of parameters, attributes and anywhere else a compile-time value is required;
  3. It's needlessly complex because constants rarely if ever change their values across versions; also, because of the tight integration C++# creates between the binding and the native library it's unsafe anyway to use a binding generated for one version with a newer one.

We can actually support (in most cases) complex constants (objects) too by using C# read-only fields. But let's just start with primitive constants: integers, Booleans, possibly strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions