Skip to content

Commit

Permalink
[tcgc] no need to add access override along with usage override for o…
Browse files Browse the repository at this point in the history
…rphan model (#1378)

this should be a bug that missing in
#925.
since we changed access default to public, we no longer need to add
access override along with usage override when we want to expose an
orphan model
  • Loading branch information
tadelesh committed Aug 15, 2024
1 parent 3fae01c commit b02eabc
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 113 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/fix_usage-2024-7-15-13-21-20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-client-generator-core"
---

no need to add access override along with usage override for orphan model
6 changes: 2 additions & 4 deletions packages/typespec-client-generator-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1709,10 +1709,8 @@ function handleServiceOrphanType(context: TCGCContext, type: Model | Enum | Unio
const sdkType = diagnostics.pipe(getClientTypeWithDiagnostics(context, type));
updateUsageOfModel(context, UsageFlags.Input | UsageFlags.Output, sdkType);
}
if (getAccessOverride(context, type) !== undefined) {
const sdkType = diagnostics.pipe(getClientTypeWithDiagnostics(context, type));
updateUsageOfModel(context, UsageFlags.None, sdkType);
}
const sdkType = diagnostics.pipe(getClientTypeWithDiagnostics(context, type));
updateUsageOfModel(context, UsageFlags.None, sdkType);
}

function verifyNoConflictingMultipartModelUsage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,6 @@ describe("typespec-client-generator-core: decorators", () => {
@test namespace MyService {
@test
@usage(Usage.input | Usage.output)
@access(Access.public)
enum Enum1{
one,
two,
Expand All @@ -2344,7 +2343,6 @@ describe("typespec-client-generator-core: decorators", () => {
@test
@usage(Usage.input | Usage.output)
@access(Access.public)
model Model1{ prop: string }
@test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,6 @@ describe("typespec-client-generator-core: public-utils", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model A {
pForA: {
name: string;
Expand Down Expand Up @@ -1545,7 +1544,6 @@ describe("typespec-client-generator-core: public-utils", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model A {
status: "start" | "stop";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe("typespec-client-generator-core: body model property types", () => {
it("required", async function () {
await runner.compileWithBuiltInService(`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
name: string | int32;
}
Expand All @@ -27,7 +26,6 @@ describe("typespec-client-generator-core: body model property types", () => {
it("optional", async function () {
await runner.compileWithBuiltInService(`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
name?: string;
}
Expand All @@ -39,7 +37,6 @@ describe("typespec-client-generator-core: body model property types", () => {
it("readonly", async function () {
await runner.compileWithBuiltInService(`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@visibility("read")
name?: string;
Expand All @@ -52,7 +49,6 @@ describe("typespec-client-generator-core: body model property types", () => {
it("not readonly", async function () {
await runner.compileWithBuiltInService(`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@visibility("read", "create", "update")
name?: string;
Expand All @@ -67,7 +63,6 @@ describe("typespec-client-generator-core: body model property types", () => {
#suppress "deprecated" "for testing"
@test
@usage(Usage.input | Usage.output)
@access(Access.public)
@projectedName("java", "JavaTest")
model Test {
@projectedName("java", "javaProjectedName")
Expand Down Expand Up @@ -125,7 +120,6 @@ describe("typespec-client-generator-core: body model property types", () => {
it("union type", async function () {
await runner.compileWithBuiltInService(`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
name: string | int32;
}
Expand Down Expand Up @@ -159,7 +153,6 @@ describe("typespec-client-generator-core: body model property types", () => {
}
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@added(Versions.v1)
@removed(Versions.v2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: string;
}
Expand All @@ -35,7 +34,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: boolean;
}
Expand Down Expand Up @@ -63,7 +61,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: ${type};
}
Expand All @@ -82,7 +79,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: ${type};
}
Expand All @@ -99,7 +95,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: decimal;
}
Expand All @@ -115,7 +110,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: decimal128;
}
Expand All @@ -131,7 +125,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: unknown;
}
Expand All @@ -145,7 +138,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: bytes;
}
Expand All @@ -161,7 +153,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(BytesKnownEncoding.base64)
prop: bytes;
Expand All @@ -178,7 +169,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(BytesKnownEncoding.base64url)
prop: bytes;
Expand All @@ -198,7 +188,6 @@ describe("typespec-client-generator-core: built-in types", () => {
scalar Base64UrlBytes extends bytes;
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
value: Base64UrlBytes[];
}
Expand All @@ -224,7 +213,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runnerWithCore.compileWithBuiltInAzureCoreService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
id: Azure.Core.armResourceIdentifier<[
{
Expand All @@ -251,7 +239,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runnerWithCore.compileWithBuiltInAzureCoreService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
urlScalar: url;
Expand Down Expand Up @@ -313,7 +300,6 @@ describe("typespec-client-generator-core: built-in types", () => {
scalar Derived extends Base;
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: Derived;
}
Expand All @@ -338,7 +324,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@format("unknown")
unknownProp: string;
Expand Down Expand Up @@ -402,7 +387,6 @@ describe("typespec-client-generator-core: built-in types", () => {
scalar TestScalar extends string;
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: TestScalar;
}
Expand All @@ -422,7 +406,6 @@ describe("typespec-client-generator-core: built-in types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(string)
value: safeint;
Expand All @@ -442,7 +425,6 @@ describe("typespec-client-generator-core: built-in types", () => {
scalar int32EncodedAsString extends int32;
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
value: int32EncodedAsString;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe("typespec-client-generator-core: constant types", () => {
it("string", async function () {
await runner.compileWithBuiltInService(`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: "json";
}
Expand All @@ -29,7 +28,6 @@ describe("typespec-client-generator-core: constant types", () => {
it("boolean", async function () {
await runner.compileWithBuiltInService(`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@test prop: true;
}
Expand All @@ -45,7 +43,6 @@ describe("typespec-client-generator-core: constant types", () => {
it("number", async function () {
await runner.compileWithBuiltInService(`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@test prop: 4;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe("typespec-client-generator-core: date-time types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: utcDateTime;
}
Expand All @@ -30,7 +29,6 @@ describe("typespec-client-generator-core: date-time types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(DateTimeKnownEncoding.rfc3339)
prop: utcDateTime;
Expand All @@ -47,7 +45,6 @@ describe("typespec-client-generator-core: date-time types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(DateTimeKnownEncoding.rfc7231)
prop: utcDateTime;
Expand All @@ -65,7 +62,6 @@ describe("typespec-client-generator-core: date-time types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: unixTimestamp32;
}
Expand All @@ -83,7 +79,6 @@ describe("typespec-client-generator-core: date-time types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(DateTimeKnownEncoding.unixTimestamp, int64)
value: utcDateTime;
Expand All @@ -107,7 +102,6 @@ describe("typespec-client-generator-core: date-time types", () => {
scalar extraLayerDateTime extends unixTimestampDatetime;
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
value: extraLayerDateTime;
}
Expand Down Expand Up @@ -135,7 +129,6 @@ describe("typespec-client-generator-core: date-time types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(DateTimeKnownEncoding.unixTimestamp, int64)
value: utcDateTime | null;
Expand All @@ -160,7 +153,6 @@ describe("typespec-client-generator-core: date-time types", () => {
scalar unixTimestampDateTime extends utcDateTime;
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
value: unixTimestampDateTime[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe("typespec-client-generator-core: duration types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
prop: duration;
}
Expand All @@ -29,7 +28,6 @@ describe("typespec-client-generator-core: duration types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(DurationKnownEncoding.ISO8601)
prop: duration;
Expand All @@ -46,7 +44,6 @@ describe("typespec-client-generator-core: duration types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(DurationKnownEncoding.seconds, int32)
prop: duration;
Expand All @@ -63,7 +60,6 @@ describe("typespec-client-generator-core: duration types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(DurationKnownEncoding.seconds, float)
prop: duration;
Expand All @@ -80,7 +76,6 @@ describe("typespec-client-generator-core: duration types", () => {
await runner.compileWithBuiltInService(
`
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
@encode(DurationKnownEncoding.seconds, float)
prop: duration | null;
Expand All @@ -105,7 +100,6 @@ describe("typespec-client-generator-core: duration types", () => {
scalar Float32Duration extends duration;
@usage(Usage.input | Usage.output)
@access(Access.public)
model Test {
value: Float32Duration[];
}
Expand Down
Loading

0 comments on commit b02eabc

Please sign in to comment.