Skip to content

December spring breaking changes and deprecations #1263

Closed

Description

No description provided.

Activity

  1. timotheeguerin commented on Nov 11, 2022

    @timotheeguerin
    MemberAuthor

    [Api] Change to onEmit signature

    The signature of onEmit has been updated.

    Before

    export function $onEmit(program: Program, options: MyEmitterOptions);

    Now

    export function $onEmit(context: EmitContext);

    Access properties

    Before Now
    program context.program
    options context.options
    options["output-dir"] context.emitterOutputDir See details

    [Cadl] [Api] Emitter option output-dir renamed to emitter-output-dir

    The option has been renamed for all emitters as emitter-output-dir is now managed in the compiler
    Before

    emitters:
      my-emitter:
        output-dir: /path/to-output-dir

    Now

    emitters:
      my-emitter:
        emitter-output-dir: {output-dir}/for-this-emitter
    #                        ^ can now reference the common output-dir

    Change to api

    Before

    export function $onEmit(program: Program, options: MyEmitterOptions) {
      const outputDir = options["output-dir"];
    }

    Now

    export function $onEmit(context: EmitContext) {
      const outputDir = context.emitterOutputDir;
    }
  2. timotheeguerin commented on Nov 18, 2022

    @timotheeguerin
    MemberAuthor

    API compiler Multiple services per cadl specs are now allowed making a service accessor obsolete.

    The following functions have been deprecated

    export function getServiceTitle(program: Program): string;
    export function getServiceVersion(program: Program): string;
    export function getServiceNamespace(program: Program): Namespace;
    export function getServiceNamespaceString(program: Program): string | undefined;
    export function setServiceNamespace(program: Program, namespace: Namespace);

    and replaced with

    export interface ServiceDetails {
      title?: string;
      version?: string;
    }
    export interface Service extends ServiceDetails {
      type: Namespace;
    }
    
    export function listServices(program: Program): Service[];
    export function getService(
      program: Program,
      namespace: Namespace
    ): Service | undefined;
    export function isService(program: Program, namespace: Namespace): boolean;
    
    export function addService(program: Program, type: Namespace, details?: ServiceDetails);

    Other changes to the service resolution:

    • Title won't be defaulted to (title)
    • Version won't be defaulted to 0000-00-00
    • Service namespace won't be defaulted to global namespace
    Before To add support for multi serviceF
    getServiceNamespace(program) listServices(program) to get all services
    getServiceNamespaceString(program) getNamespaceName(service.type) is where service is getService(program, serviceNamespace)
    getServiceTitle(program) service.title where service is getService(program, serviceNamespace)
    getServiceVersion(program) service.version where service is getService(program, serviceNamespace)
  3. timotheeguerin commented on Nov 21, 2022

    @timotheeguerin
    MemberAuthor

    Cadl Api Compiler Moved cadl intrinsic types to a new Type scalar

    A new type has been introduced to cadl in order to differentiate scalar from structured models types. Those new types can be declared using scalar and can extend another scalar using extends.

    Change to cadl intrinsic models

    All of Cadl intrinsic models have been updated to be scalar types instead of model. In most cases this shouldn't affect a spec but if you are defining a custom model that is one of the intrinsic types you'll have to update it

    Before

    model MyStr is string;
    

    After

    scalar MyStr extends string;
    

    Migration script

    The following script can be used to automatically migrate previous usages.

    npx @cadl-lang/migrate
    

    Change to Compiler API

    Removed:

    • getIntrinsicModelName: Check it is a std type with program.checker.isStdType(type) and then use the type.name otherwise look for type.baseScalar
    • isIntrinsic: Check it is a std type with program.checker.isStdType(type) or just remove the check if goal was to omit intrinsic types from models.

    Migration:

    1. Add a new switch to handle the new scalar type
    2. To resolve a scalar type, check if its a std type using program.checker.isStdType(type)
    3. If yes, do the same behavior has before with getIntrinsicModelName
    4. If not, call scalar.baseScalar and repeat step 2.
  4. nguerrera commented on Nov 28, 2022

    @nguerrera
    Contributor

    Directives can no longer be placed in certain contexts.

    For example, this is no longer valid:

    model M<
    #suppress example
    T
    > {}
    

    And will now result in an error "Cannot place directive on template parameter".

    Move such directives up to the nearest statement, interface operation, model property, operation parameter, union variant, or enum member.

    For the above example, that would be:

    #suppress example
    model M<T> {}
    
  5. tjprescott commented on Dec 2, 2022

    @tjprescott
    Member

    cadl-rest

    • @segmentSeparator is deprecated. The @actionSeparator decorator should be used instead.
  6. timotheeguerin commented on Dec 2, 2022

    @timotheeguerin
    MemberAuthor

    Cadl Deprecated uri being replaced by url

    Before:

    model Server {
      endpoint: uri
    }
    

    Now:

    model Server {
      endpoint: url
    }
    
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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions