Skip to content

Add Code Literal Generation to Type Mapping #8741

Closed

Description

@bricelam

Currently, all intrinsic types are handled by ICSharpHelper (or ICSharpUtilities for RevEng), and if we encounter a type we don't understand, we'll throw.

Instead of throwing, we should ask the provider if they know how to generate a literal for the type. We'll do this by adding a method similar to the following to RelationalTypeMapping.

string GenerateCodeLiteral(object value, string language)

language will probably be the file extension of the code file we're generating (e.g. .cs for C#).

If a value is returned, we'll use it. If null is returned we'll continue to error with unknown literal.

Optionally, we could move the existing literal generation code to the type mappings so that they become the source of truth for all literal generation.

If an application wanted to support literal generation for a new language (e.g. Visual Basic or F#), they could override the provider type mapping implementation to handle that language.

Activity

  1. divega commented on Jun 6, 2017

    @divega
    Contributor

    @bricelam thanks for writing this down. Question: do you envision the language parameter also in the methods of the "built-in" literal generation code (i.e. what currently lives in ICSharpHelp and ICSharpUtilities)? Perhaps it is ok to punt altogether on the multi-language support, but it might be relevant since you are working on #1671.

  2. divega commented on Jun 6, 2017

    @divega
    Contributor

    @bricelam I guess I am just being skeptical about the language parameter approach. Nothing to worry about in the short term.

  3. added this to the Backlog milestone on Jun 12, 2017
  4. ajcvickers commented on Aug 13, 2018

    @ajcvickers
    Contributor

    See also #12979.

    Removing this from backlog to see if we want to do this in 3.0, where we may be able to break if it becomes necessary.

  5. modified the milestones: Backlog, 3.0.0 on Aug 13, 2018
  6. modified the milestones: 3.0.0, on Sep 12, 2018
  7. modified the milestones: , 2.2.0 on Nov 11, 2019
  8. removed their assignment
    on Sep 1, 2024
  9. added theissue type on Jun 15, 2025
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions