Idea that could be expanded/exposed to other libraries in the future.
Define clearly how to access a certain state key.
Doing that now as for paging there is a lot of decorators that are added
and that will simplify.
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
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;
}
```
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.
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.
Fixes#4259Fixes#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>
- 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
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.
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
```
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">
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.
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.
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.