Граф коммитов

2548 Коммитов

Автор SHA1 Сообщение Дата
Xiaofei Cao 4b942c9fb9
java mgmt, skip validate on resource properties (#4431)
If parent model doesn't have validate() method on it, don't validate
parent model's properties.
Specially for `Resource`'s `location` property.
2024-09-14 02:15:16 +00:00
Timothee Guerin b1753b66a2
Add config for mc0 and ms1 cookies (#4443) 2024-09-13 23:04:23 +00:00
Timothee Guerin 3d14d7c2c9
Bump dependencies - Sep 2024 (#4424)
Notable: 
- Typescript 5.6: iterator functions  and more
- typescript-eslint 8: new rules, breaking change to some other, found a
few bugs/test not actually testing
- eslint 9: new rules
- removed deprecation/deprecation plugin as typescript eslint has rule
for it now(and updated) many places where it wasn't reporting correctly
2024-09-13 15:50:22 +00:00
Dapeng Zhang c6130786a8
fix an exception message issue in MrwSerializationTypeDefinition (#4432) 2024-09-13 10:51:25 +00:00
Weidong Xu 72478a51b4
http-client-java, access/usage on namespace (#4417)
1. basic logic is that if there is not access/usage decorator on model,
check the decorator on its parent
2. a cache is put so that one namespace is only checked once
(`undefined` is also included as a result) <-- it is just performance

There is a corner case that

```ts
@usage(Usage.input)
namespace L1 {
  @usage(Usage.output)
  namespace L2 {
    model M {}
  }
}
```
that in some interpretation M may be input+output. But TCGC and the
logic in PR both gives output. I guess this be OK.

Local test (as TCGC seems not able to handle my case in cadl-ranch, that
models is defined in a sub namespace)
```
@supportedBy("dpg")
@scenarioService("/client/initialization")
@access(Access.public)
@usage(Usage.output)
namespace Client.AccessTest;

// public output
model OutputModel {
  name: string;
}

// public output
model OutputModel2 {
  name: string;
}

// internal input+output
@access(Access.internal)
@usage(Usage.input | Usage.output)
model Model3 {
  name: string;
}

@access(Access.internal)
namespace InternalOperations {
// internal
  op get(): OutputModel;
}
```
2024-09-13 09:08:37 +00:00
Crystal YU 40762bf852
upgrade typespec to 0.60.0 (#4397)
Fix https://github.com/microsoft/typespec/issues/4396

- upgrade typespec to 0.60.0, and tcgc to 0.46.0
2024-09-13 08:46:37 +00:00
Dapeng Zhang 710abdcc41
Fix the type cache with extensibility (#4427)
Fixes #4428 

This PR also fixes the incorrect caching system for `CreateCSharpType`.
The `CreateCSharpType` is the entry point, therefore the type cache
should work here - and all the invocations in the `CreateCSharpTypeCore`
should be verified that this input is not in the cache, therefore the
cache should never be accessed again once we go into this method.
2024-09-13 07:22:44 +00:00
Rodge Fu e6d426eeeb
Support compile and watch tasks in vscode (#4330)
Add support of Compile Task and Watch Tasks in vscode.  fixes #2082
2024-09-13 01:23:53 +00:00
Timothee Guerin 4a8556c6c2
Bump compiler version for 0.60.1 hotfix (#4421) 2024-09-12 21:32:06 +00:00
Jorge Rangel af9a2eb36a
Refactor additional properties in models (#4400)
Contributes to https://github.com/microsoft/typespec/issues/4007 by
refactoring how additional properties are generated. The serialization
changes will be included in follow up PR(s).
2024-09-12 20:22:08 +00:00
Timothee Guerin 5fa9d4c27c
Fix numeric issues with exponential notation (#4420)
fix #4419
2024-09-12 19:43:02 +00:00
m-nash 4dcc475ca1
Http payload multipart (#4413)
Fixes https://github.com/microsoft/typespec/issues/3981
2024-09-12 19:26:31 +00:00
Weidong Xu deae32ea6f
http-client-java, support client parameter to client (#4415)
This is only part of the support for
https://github.com/Azure/autorest.java/issues/2428

cadl-ranch https://github.com/Azure/cadl-ranch/pull/727

user code
```java
        InitializationClient client = new InitializationClientBuilder()
            .name("client1")
            .buildClient();
        client.action();
```
2024-09-12 08:18:25 +00:00
Dapeng Zhang f9ae0a1daf
fix the keyCredential issue (#4412)
Fixes #4411
This change gives the azure plugin the ability to change the type of the
credentials, but it will still have to override everything in
ClientProvider to use the token credential.
Maybe only a credential abstraction change could solve it, but it needs
more discussions.
2024-09-12 03:04:29 +00:00
Christopher Radek e62e58a62e
Prepare 0.60.1 hotfix release (#4409)
Release for #4408

Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-09-11 23:37:21 +00:00
Christopher Radek 32a118dbf6
Fixes versioning when using versioned named union variants (#4408)
Example of bug:
[playground](https://typespec.io/playground?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZdmVyc2lvbmluZyI7Cgp1c2luZyBUeXBlU3BlYy5WyR070BtIdHRw0RVSZXN0OwoKQMdVZWQox0JzKQpAc2VydmljZSh7CiAgdGl0bGU6ICJXaWRnZXQgU8YbIiwKfSkKbmFtZXNwYWNlIERlbW%2FHGzsKCmVudW0gyFAgxEZ2MSzEBjIsCn0KCnVuaW9uIEZvb0NvbnRlbnTFInN0cmluZywKCiAgQGFkZOsAkS52MikKIMQwOsQFW13FRdQlbW9kZWzEJMVS5AE5OsdYO9UzMcgzQ2hhdFJlcXVlc%2BYAjWPmAJnFcOcApTsKICDkAPA%2FzVNhbGlhcyBPdGhlclXlANY9xx4gfMQ8W107Cg%3D%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)

---------

Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-09-11 22:50:14 +00:00
Dapeng Zhang 7d444a4331
Support to change the accessibility of a model and change a model to be struct via customized code (#4347)
Fixes #4259 
Fixes #4346 

I change the structure of test data for those customization code related
test cases, now it should be a directory with the name of the test
method, in which we could put all of customization code because in quite
a few scenarios we might need multiple files there.

---------

Co-authored-by: m-nash <64171366+m-nash@users.noreply.github.com>
2024-09-11 19:57:16 +00:00
JoshLove-msft a5fc2ce620
Customization fixes (#4385)
- ClientModelPlugin.AdditionalMetadataReferences now includes
System.Memory.Data and System.Text.Json in order to allow Roslyn to
parse types from these assemblies found in custom code. BinaryData and
IJsonModel (which references Utf8JsonWriter) are common in customized
partial classes.
- AdditionalMetadataReferences were not added to the compilation for
custom code which would cause Roslyn to not load the additional
references correctly
- Even after fixing the above two issues, framework types that are not a
dependency of the generator, e.g. BinaryData, would not be found by
Type.GetType call in NamedTypeSymbolProvider. To work around this issue,
we will create a new CSharpType for such framework types using all of
the ISymbol information as inputs.
- Add handling for malformed xml docs
2024-09-11 05:39:45 +00:00
Weidong Xu 2010bc4490
http-client-java, compiler 0.46 (#4393) 2024-09-11 03:08:01 +00:00
Christopher Radek 0be9e8f22b
TypeSpec 0.59 - September Release branch (#4386)
Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-09-10 22:45:59 +00:00
Christopher Radek bc68f8499a
Add release notes for version 0.60.0 (#4384)
Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
2024-09-10 18:44:51 +00:00
Weidong Xu 99abec93e9
http-client-java_add-cadl-ranch-tests (#4368)
add cadl-ranch tests

main focus is routes
2024-09-10 05:45:00 +00:00
Weidong Xu 27c263ee68
http-client-java, corner case of client without op or group (#4358)
Found when trying to write subclass as 
```ts
@client({
  name: "ContosoClient",
  service: Cadl.ContosoServer,
})
namespace Cadl.ContosoServer {
  @client({
    name: "ContosoSubClient",
    service: Cadl.ContosoServer,
  })
  namespace SubClient {
    @client({
      name: "ContosoSubSubClient",
      service: Cadl.ContosoServer,
    })
    @route("/contoso/")
    interface ServerOp {
      get(@path(#{ allowReserved: true }) group: string): OkResponse | NoContentResponse;
    }
  }
}
```

<-- this likely not the correct way to write subclient (as Client be
very different from subclient from nested namespace), but at least
emitter should not throw

After this PR, above tsp would result in `ContosoSubSubClient` client,
as this is the only one containing operation.
2024-09-10 04:26:01 +00:00
Alitzel Mendez 5a55338def
[Bug] Fix semantic walker not firing exitOperation or exitModelProperty (#4381)
Fix: https://github.com/microsoft/typespec/issues/4379
2024-09-10 04:08:55 +00:00
Alan Zimmer c6809aa94d
Porting fix from autorest.java (#4371)
https://github.com/Azure/autorest.java/pull/2943

Co-authored-by: Weidong Xu <weidxu@microsoft.com>
2024-09-10 02:56:09 +00:00
JoshLove-msft a714eea53c
Move property name set to ModelProvider (#4374)
Avoids having two separate backing lists which could become out of sync.
2024-09-09 20:51:59 +00:00
Timothee Guerin f4c8710673
Fix set response doc when an envelope (#4322)
fix [#3664](https://github.com/microsoft/typespec/issues/3664)
2024-09-06 23:45:59 +00:00
Timothee Guerin d2ac995842
Extract source resolution logic into its own source loader (#4324)
This will allow other tools to be able to reuse the typespec compiler
source resolution logic(Figure out all the imported files) without doing
a full compile and cleans up the program.ts which is doing a lot of
things.

Usage

```ts
const loader = createSourceLoader(host);

loader.importFile(resolvePath(cwd, "main.tsp", {type: "project"}));

loader.importPath("./foo.tsp", NoTarget, cwd, {type: "project"} );

loader.resolution.sourceFiles // Tsp source files loaded
loader.resolution.jsSourceFiles // Js source file loaded
```
2024-09-06 23:24:59 +00:00
Timothee Guerin dde8dc0ca7
Add api extractor for openapi package and fix issues (#4354) 2024-09-06 23:18:53 +00:00
JoshLove-msft 86cc361bf0
Add tests for changing property type/accessibility (#4365)
Validates that https://github.com/microsoft/typespec/issues/4258 and
https://github.com/microsoft/typespec/issues/4265 are fixed. They were
fixed by https://github.com/microsoft/typespec/pull/4362.
2024-09-06 22:56:05 +00:00
JoshLove-msft 782dca54ed
Support customizing property names (#4362)
Fixes https://github.com/microsoft/typespec/issues/4257
2024-09-06 21:35:58 +00:00
Timothee Guerin 03d4fca5c0
Improvements to type relation errors (#4357)
fix https://github.com/microsoft/typespec/issues/3291

Changes: 
1. Figure out the most accurate location for the diagnostic
2. If diagnostic target a child node of the base diagnostic target then
emit diagnostic directly there
3. Otherwise emit back at the root(or closest child node) and build
stack of error message

Example the following would now emit the error on a
```ts
 const b = #{ prop: #{a: "abc"}};
 const a: {prop: {}} = b;
```

```
Type '{ prop: { a: "abc" } }' is not assignable to type '{ prop: {} }'
  Type '{ a: "abc" }' is not assignable to type '{}'
    Object value may only specify known properties, and 'a' does not exist in type '{}'.
```

Previously the error would have been in the complete wrong place 
<img width="271" alt="image"
src="https://github.com/user-attachments/assets/c403d1ec-3611-4ad6-87b0-2e0a075dc1c5">
2024-09-06 21:07:18 +00:00
Dapeng Zhang 89e19ef521
Change the property names to be lower case letter in the tspCodeModel.json (#4331)
Fixes https://github.com/Azure/autorest.csharp/issues/4715

This PR changes the property names for models and enums in the
`tspCodeModel.json` to be lower cases to align convention and the type
definitions in TCGC.
clients and operations are untouched in this PR, we could make follow up
on those later.
2024-09-06 07:32:45 +00:00
Weidong Xu d836c427be
http-client-java, sync code from autorest.java (#4345)
sync https://github.com/Azure/autorest.java/pull/2936
change to JavaSettings,java is already included in prior sync PR.

This should be the last PR we need to sync.
2024-09-06 06:33:29 +00:00
Weidong Xu 7219aa4035
http-client-java, update cadl-ranch, handle TCGC multipart logic (#4352)
pending issue at https://github.com/Azure/typespec-azure/issues/1488
2024-09-06 06:04:23 +00:00
Srikanta f329e038f8
Java codegen: disable dependency transfer logging (#4355)
Maven build logs all dependency transfers and is too verbose. This PR
disables dependency transfer logging to keep the pipeline logs clean.
2024-09-06 02:07:51 +00:00
Timothee Guerin 1c2154cbda
Fix anonymous union variant in tree viewer (#4353)
fix https://github.com/Azure/typespec-azure/issues/1480
2024-09-05 17:45:19 +00:00
Dapeng Zhang ad635d920e
Align the structure of model property (#4319)
Fixes https://github.com/Azure/autorest.csharp/issues/4793
2024-09-05 06:20:02 +00:00
m-nash 06c0bb5dca
Handle replacement properties (#4325)
Supports https://github.com/microsoft/typespec/issues/3981

These cadl ranch tests have models which use replacement properties in
extended types that we need to handle.
2024-09-05 02:12:37 +00:00
Xiaofei Cao 93377fd7dd
java generator, fix generator-test when running from main (#4334)
- Part of https://github.com/microsoft/typespec/pull/4315, though before
TypeSpec ARM fix, we'll probably will not merge that PR
2024-09-05 01:57:34 +00:00
JoshLove-msft 244dbc08c0
Use the Cat model in tests (#4341)
Fix to https://github.com/microsoft/typespec/pull/4301. The PR was
updated to always keep Union models, so we don't need the reflection
workaround.
2024-09-04 23:43:54 +00:00
Weidong Xu b645fb3d6d
http-client-java, remove unused namer module (#4328)
History: we originally intend to use m4 prenamer (opt-in via
flag/option) to keep names in SDK same as from Swagger (mostly for
brownfield).

But later we decided to just use `@clientName` in client.tsp to
explicitly do the naming, if backward-compatibility is an issue.

This flag/option is not used by any service.
2024-09-04 23:12:53 +00:00
JoshLove-msft 1dcd5c4c36
Prune unreferenced files (#4301)
Fixes https://github.com/microsoft/typespec/issues/4218

Replaces https://github.com/microsoft/typespec/pull/4288
2024-09-04 22:25:36 +00:00
Timothee Guerin 12ccdd1818
Refactor: Separate type relation logic from checker.ts (#4337)
The type relation logic is already quite sizable and isn't really tied
to the checker too much.
Apart from accessing std types it can be self contained. This should
help maintaining it.
2024-09-04 22:01:36 +00:00
Dapeng Zhang cd6e362df8
implement the feature of changing the name of a model (#4285)
Fixes #4256 
Fixes #4261

In order to get our mocking system working properly and make everything
aligned, I changed the `SourceInputModel` to public and added it to the
`CodeModelPlugin` so that our plugin writers could override something on
it to do some advanced stuffs
2024-09-04 21:24:41 +00:00
Timothee Guerin 04b198693d
Setup api extractor for xml library (#4335)
Ideally we can connect that to api view to report changes to the api
without having to commit extra files to the repo.

But for now this at least enforce the good pattern for api extractor
2024-09-04 21:12:36 +00:00
Timothee Guerin 74627ec770
Fix labels CI (#4336)
Seems like that was merged with conflict or failure
2024-09-04 17:58:53 +00:00
Wei Hu eacbc248f8
Remove extra space to fix VS debug attachment (#4333)
Resolves https://github.com/microsoft/typespec/issues/4332

extra space in argument for `child_process.spawn` ended up into missing
2024-09-04 09:23:17 +00:00
Srikanta 0f8dcf4ea0
Remove unused test directory (#4318) 2024-09-04 02:06:37 +00:00
Srikanta 73e61f9202
Java codegen - clean up build steps (#4323)
This PR cleans up some of the build steps that are not required. Latest
JDK LTS version (Java 21) is pre-installed in 1es hosts and we don't
need to explicitly download and install this. So, this PR comments out
the code that does this as we might still need this in the future to
install newer versions of Java that are not available on 1es.
2024-09-04 02:03:41 +00:00