Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import { UsageFlags } from "@azure-tools/typespec-client-generator-core";
import { resolvePath } from "@typespec/compiler";
import { configurationFileName, tspOutputFileName } from "./constants.js";
import { CSharpEmitterContext } from "./sdk-context.js";
import { CodeModel } from "./type/code-model.js";
import { Configuration } from "./type/configuration.js";
import type { CSharpEmitterContext } from "./sdk-context.js";
import type { CodeModel } from "./type/code-model.js";
import type { Configuration } from "./type/configuration.js";

/**
* Serializes the code model to a JSON string with reference tracking.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { resolvePath } from "@typespec/compiler";
import type { GenerateOptions } from "./emit-generate.js";
import { CSharpEmitterContext } from "./sdk-context.js";
import type { CSharpEmitterContext } from "./sdk-context.js";

const SERVER_URL = "https://csharp-playground-server.azurewebsites.net";
const MAX_RESPONSE_SIZE = 10 * 1024 * 1024; // 10 MB
Expand Down
4 changes: 2 additions & 2 deletions packages/http-client-csharp/emitter/src/emit-generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

// Node.js implementation: runs the .NET generator locally via subprocess.

import type { Diagnostic } from "@typespec/compiler";
import {
createDiagnosticCollector,
Diagnostic,
getDirectoryPath,
joinPaths,
NoTarget,
Expand All @@ -21,7 +21,7 @@ import {
} from "./constants.js";
import { execAsync, execCSharpGenerator } from "./lib/exec-utils.js";
import { createDiagnostic } from "./lib/lib.js";
import { CSharpEmitterContext } from "./sdk-context.js";
import type { CSharpEmitterContext } from "./sdk-context.js";

export interface GenerateOptions {
outputFolder: string;
Expand Down
22 changes: 10 additions & 12 deletions packages/http-client-csharp/emitter/src/emitter.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import { createSdkContext, SdkContext } from "@azure-tools/typespec-client-generator-core";
import {
createDiagnosticCollector,
Diagnostic,
EmitContext,
Program,
resolvePath,
} from "@typespec/compiler";
import type { SdkContext } from "@azure-tools/typespec-client-generator-core";
import { createSdkContext } from "@azure-tools/typespec-client-generator-core";
import type { Diagnostic, EmitContext, Program } from "@typespec/compiler";
import { createDiagnosticCollector, resolvePath } from "@typespec/compiler";
import { serializeCodeModel } from "./code-model-writer.js";
import { generate } from "./emit-generate.js";
import { createModel } from "./lib/client-model-builder.js";
import { LoggerLevel } from "./lib/logger-level.js";
import { Logger } from "./lib/logger.js";
import { CSharpEmitterOptions, resolveOptions } from "./options.js";
import { createCSharpEmitterContext, CSharpEmitterContext } from "./sdk-context.js";
import { CodeModel } from "./type/code-model.js";
import { Configuration } from "./type/configuration.js";
import type { CSharpEmitterOptions } from "./options.js";
import { resolveOptions } from "./options.js";
import type { CSharpEmitterContext } from "./sdk-context.js";
import { createCSharpEmitterContext } from "./sdk-context.js";
import type { CodeModel } from "./type/code-model.js";
import type { Configuration } from "./type/configuration.js";

/**
* Creates a code model by executing the full emission logic.
Expand Down
15 changes: 6 additions & 9 deletions packages/http-client-csharp/emitter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ export { createModel } from "./lib/client-model-builder.js";
export { $lib, createDiagnostic, getTracer, reportDiagnostic } from "./lib/lib.js";
export { LoggerLevel } from "./lib/logger-level.js";
export { Logger } from "./lib/logger.js";
export {
CSharpEmitterOptions,
CSharpEmitterOptionsSchema,
defaultOptions,
resolveOptions,
} from "./options.js";
export { CSharpEmitterOptionsSchema, defaultOptions, resolveOptions } from "./options.js";
export type { CSharpEmitterOptions } from "./options.js";
// we export `createCSharpEmitterContext` only for autorest.csharp because it uses the emitter to generate the code model file but not calling the dll here
// we could remove this export when in the future we deprecate autorest.csharp
export { $dynamicModel, isDynamicModel } from "./lib/decorators.js";
export { CSharpEmitterContext, createCSharpEmitterContext } from "./sdk-context.js";
export { CodeModel } from "./type/code-model.js";
export { InputClient, InputModelType } from "./type/input-type.js";
export { createCSharpEmitterContext } from "./sdk-context.js";
export type { CSharpEmitterContext } from "./sdk-context.js";
export type { CodeModel } from "./type/code-model.js";
export type { InputClient, InputModelType } from "./type/input-type.js";

/** @internal */
export { $decorators } from "./tsp-index.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import {
import type {
SdkClientType as SdkClientTypeOfT,
SdkCredentialParameter,
SdkEndpointParameter,
SdkEndpointType,
SdkHttpOperation,
SdkMethodParameter,
} from "@azure-tools/typespec-client-generator-core";
import { createDiagnosticCollector, Diagnostic, NoTarget } from "@typespec/compiler";
import { CSharpEmitterContext } from "../sdk-context.js";
import type { Diagnostic } from "@typespec/compiler";
import { createDiagnosticCollector, NoTarget } from "@typespec/compiler";
import type { CSharpEmitterContext } from "../sdk-context.js";
import { InputParameterScope } from "../type/input-parameter-scope.js";
import {
import type {
InputClient,
InputEndpointParameter,
InputParameter,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import {
import type {
SdkClientType,
SdkEnumType,
SdkHttpOperation,
} from "@azure-tools/typespec-client-generator-core";
import { createDiagnosticCollector, Diagnostic, NoTarget } from "@typespec/compiler";
import { CSharpEmitterContext } from "../sdk-context.js";
import { CodeModel } from "../type/code-model.js";
import { InputEnumType, InputLiteralType, InputModelType } from "../type/input-type.js";
import type { Diagnostic } from "@typespec/compiler";
import { createDiagnosticCollector, NoTarget } from "@typespec/compiler";
import type { CSharpEmitterContext } from "../sdk-context.js";
import type { CodeModel } from "../type/code-model.js";
import type { InputEnumType, InputLiteralType, InputModelType } from "../type/input-type.js";
import { fromSdkClients } from "./client-converter.js";
import { createDiagnostic } from "./lib.js";
import { fromSdkNamespaces } from "./namespace-converter.js";
Expand Down
8 changes: 4 additions & 4 deletions packages/http-client-csharp/emitter/src/lib/decorators.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import { SdkContext } from "@azure-tools/typespec-client-generator-core";
import {
import type { SdkContext } from "@azure-tools/typespec-client-generator-core";
import type {
DecoratedType,
DecoratorContext,
Model,
Namespace,
Operation,
Program,
Type,
setTypeSpecNamespace,
} from "@typespec/compiler";
import { setTypeSpecNamespace } from "@typespec/compiler";
import type { DynamicModelDecorator } from "../../../generated-defs/TypeSpec.HttpClient.CSharp.js";
import { ExternalDocs } from "../type/external-docs.js";
import type { ExternalDocs } from "../type/external-docs.js";

/**
* The fully qualified decorator name pattern for the dynamicModel decorator.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import {
import type {
SdkArrayExampleValue,
SdkBooleanExampleValue,
SdkDictionaryExampleValue,
Expand All @@ -16,9 +16,10 @@ import {
SdkUnionExampleValue,
SdkUnknownExampleValue,
} from "@azure-tools/typespec-client-generator-core";
import { createDiagnosticCollector, Diagnostic } from "@typespec/compiler";
import { CSharpEmitterContext } from "../sdk-context.js";
import {
import type { Diagnostic } from "@typespec/compiler";
import { createDiagnosticCollector } from "@typespec/compiler";
import type { CSharpEmitterContext } from "../sdk-context.js";
import type {
InputArrayExampleValue,
InputBooleanExampleValue,
InputDictionaryExampleValue,
Expand All @@ -33,7 +34,7 @@ import {
InputUnknownExampleValue,
OperationResponseExample,
} from "../type/input-examples.js";
import {
import type {
InputArrayType,
InputDictionaryType,
InputHttpParameter,
Expand Down
8 changes: 5 additions & 3 deletions packages/http-client-csharp/emitter/src/lib/exec-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
// file so that browser bundles (which do not support `child_process`) do not
// pull them in transitively via `lib/utils.ts`.

import { NoTarget, Type } from "@typespec/compiler";
import { spawn, SpawnOptions } from "child_process";
import { CSharpEmitterContext } from "../sdk-context.js";
import type { Type } from "@typespec/compiler";
import { NoTarget } from "@typespec/compiler";
import type { SpawnOptions } from "child_process";
import { spawn } from "child_process";
import type { CSharpEmitterContext } from "../sdk-context.js";

export async function execCSharpGenerator(
context: CSharpEmitterContext,
Expand Down
8 changes: 2 additions & 6 deletions packages/http-client-csharp/emitter/src/lib/lib.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import {
createTypeSpecLibrary,
DiagnosticDefinition,
DiagnosticMessages,
paramMessage,
} from "@typespec/compiler";
import type { DiagnosticDefinition, DiagnosticMessages } from "@typespec/compiler";
import { createTypeSpecLibrary, paramMessage } from "@typespec/compiler";
import { CSharpEmitterOptionsSchema } from "../options.js";

export type DiagnosticMessagesMap = {
Expand Down
2 changes: 1 addition & 1 deletion packages/http-client-csharp/emitter/src/lib/logger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import { Program, Tracer } from "@typespec/compiler";
import type { Program, Tracer } from "@typespec/compiler";
import { getTracer } from "./lib.js";
import { LoggerLevel } from "./logger-level.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { SdkHttpOperation, SdkNamespace } from "@azure-tools/typespec-client-generator-core";
import { createDiagnosticCollector, Diagnostic } from "@typespec/compiler";
import { CSharpEmitterContext } from "../sdk-context.js";
import { InputNamespace } from "../type/input-type.js";
import type { SdkHttpOperation, SdkNamespace } from "@azure-tools/typespec-client-generator-core";
import type { Diagnostic } from "@typespec/compiler";
import { createDiagnosticCollector } from "@typespec/compiler";
import type { CSharpEmitterContext } from "../sdk-context.js";
import type { InputNamespace } from "../type/input-type.js";

export function fromSdkNamespaces(
sdkContext: CSharpEmitterContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import {
getClientNamespace,
getClientOptions,
getHttpOperationParameter,
getParamAlias,
isHttpMetadata,
import type {
SdkBodyParameter,
SdkBuiltInKinds,
SdkContext,
Expand All @@ -25,25 +20,32 @@ import {
SdkServiceMethod,
SdkServiceResponseHeader,
SdkType,
} from "@azure-tools/typespec-client-generator-core";
import {
getClientNamespace,
getClientOptions,
getHttpOperationParameter,
getParamAlias,
isHttpMetadata,
shouldGenerateConvenient,
shouldGenerateProtocol,
} from "@azure-tools/typespec-client-generator-core";
import type { Diagnostic } from "@typespec/compiler";
import {
createDiagnosticCollector,
Diagnostic,
getDeprecated,
isErrorModel,
NoTarget,
} from "@typespec/compiler";
import { HttpStatusCodeRange } from "@typespec/http";
import type { HttpStatusCodeRange } from "@typespec/http";
import { getResourceOperation } from "@typespec/rest";
import { CSharpEmitterContext } from "../sdk-context.js";
import type { CSharpEmitterContext } from "../sdk-context.js";
import { collectionFormatToDelimMap } from "../type/collection-format.js";
import { HttpResponseHeader } from "../type/http-response-header.js";
import { InputConstant } from "../type/input-constant.js";
import { InputOperation } from "../type/input-operation.js";
import type { HttpResponseHeader } from "../type/http-response-header.js";
import type { InputConstant } from "../type/input-constant.js";
import type { InputOperation } from "../type/input-operation.js";
import { InputParameterScope } from "../type/input-parameter-scope.js";
import {
import type {
InputBasicServiceMethod,
InputContinuationToken,
InputLongRunningPagingServiceMethod,
Expand All @@ -55,7 +57,7 @@ import {
InputServiceMethod,
InputServiceMethodResponse,
} from "../type/input-service-method.js";
import {
import type {
InputBodyParameter,
InputHeaderParameter,
InputHttpParameter,
Expand All @@ -65,7 +67,7 @@ import {
InputType,
} from "../type/input-type.js";
import { convertLroFinalStateVia } from "../type/operation-final-state-via.js";
import { OperationResponse } from "../type/operation-response.js";
import type { OperationResponse } from "../type/operation-response.js";
import { RequestLocation } from "../type/request-location.js";
import { parseHttpRequestMethod } from "../type/request-method.js";
import { ResponseLocation } from "../type/response-location.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import {
import type {
SdkCredentialParameter,
SdkCredentialType,
SdkHttpOperation,
SdkPackage,
} from "@azure-tools/typespec-client-generator-core";
import { createDiagnosticCollector, Diagnostic, NoTarget } from "@typespec/compiler";
import { Oauth2Auth, OAuth2Flow } from "@typespec/http";
import { CSharpEmitterContext } from "../sdk-context.js";
import { InputAuth } from "../type/input-auth.js";
import { InputOAuth2Flow } from "../type/input-oauth2-auth.js";
import type { Diagnostic } from "@typespec/compiler";
import { createDiagnosticCollector, NoTarget } from "@typespec/compiler";
import type { Oauth2Auth, OAuth2Flow } from "@typespec/http";
import type { CSharpEmitterContext } from "../sdk-context.js";
import type { InputAuth } from "../type/input-auth.js";
import type { InputOAuth2Flow } from "../type/input-oauth2-auth.js";
import { createDiagnostic } from "./lib.js";

export function processServiceAuthentication(
Expand Down
15 changes: 9 additions & 6 deletions packages/http-client-csharp/emitter/src/lib/type-converter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import {
import type {
DecoratorInfo,
getAccessOverride,
isHttpMetadata,
SdkArrayType,
SdkBuiltInType,
SdkConstantType,
Expand All @@ -18,12 +16,17 @@ import {
SdkModelType,
SdkType,
SdkUnionType,
} from "@azure-tools/typespec-client-generator-core";
import {
getAccessOverride,
isHttpMetadata,
UsageFlags,
} from "@azure-tools/typespec-client-generator-core";
import { createDiagnosticCollector, Diagnostic, Model, NoTarget } from "@typespec/compiler";
import type { Diagnostic, Model } from "@typespec/compiler";
import { createDiagnosticCollector, NoTarget } from "@typespec/compiler";
import { _httpFileCrossLanguageDefinitionId } from "../constants.js";
import { CSharpEmitterContext } from "../sdk-context.js";
import {
import type { CSharpEmitterContext } from "../sdk-context.js";
import type {
InputArrayType,
InputDateTimeType,
InputDictionaryType,
Expand Down
Loading
Loading