Skip to content

[Bug]: http-server-csharp: Generated model file is empty and produces a warning: Inline models use generated names in emitted code. Consider defining each model with an explicit name. #11451

Description

@abatishchev

Describe the bug

All warnings:

typespec/node_modules/@azure-tools/typespec-azure-core/lib/traits.tsp:147:20 - warning @typespec/http-server-csharp/anonymous-model: Inline models use generated names in emitted code. Consider defining each model with an explicit name.  This model will be named 'Model0' in emitted code
> 147 |   clientRequestId: {};
      |                    ^^
typespec/node_modules/@azure-tools/typespec-azure-core/lib/traits.tsp:177:24 - warning @typespec/http-server-csharp/anonymous-model: Inline models use generated names in emitted code. Consider defining each model with an explicit name.  This model will be named 'Model1' in emitted code
> 177 |   conditionalRequests: {};
      |                        ^^
typespec/node_modules/@azure-tools/typespec-azure-core/lib/traits.tsp:206:23 - warning @typespec/http-server-csharp/anonymous-model: Inline models use generated names in emitted code. Consider defining each model with an explicit name.  This model will be named 'Model2' in emitted code
> 206 |   repeatableRequests: {};
      |                       ^^

Resulting C# class:

// Generated by @typespec/http-server-csharp
// <auto-generated />
#nullable enable

using System;
using System.Collections.Generic;
using System.Text.Json;
using TypeSpec.Helpers;
using TypeSpec.Helpers.JsonConverters;

namespace Microsoft.MyRpNamespace;

public partial class Model0 {}

Reproduction

  1. Use an ARM RP typespec
  2. Add the following to tspconfig.yaml
emit:
  - "@typespec/http-server-csharp"
options:
  "@typespec/http-server-csharp":
    emitter-output-dir: "{project-root}/generated/{emitter-name}"
    output-type: all
    emit-mocks: none
    overwrite: true

Checklist

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions