You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
runProjection(program, [
{
projection: "Cadl.target" // use the fully qualified name
arguments: ["json"]
},
{
projection: program.resolveReference("Cadl.target"), // Or resolve the projection reference manually.
arguments: ["json"]
},
]
2. Define arguments on the projection declaration
Change
The projection declaration define the list of arguments that are expected.
Move the argument list to the project declaration
Effect:
This makes it that to and from MUST have the same arguments.
projection target(targetName);
project model#target(targetName) {
to{ ... }
from { ... }
}
// Could name the parameter differently.
project interface#target(targetId) {
to{ ... }
from { ... }
}
3. Add typing to arguments
Changes:
Projection declaration can define the types.
Could type be optional?
Projection implementation has to redefine the parameter(s) but the type can be inferred
If type is specified explicitly it MUST match exactly the one on the projection declaration.
Effect:
Running a projection will emit diagnostic if passing invalid arguments.
projection target(targetName: StringLiteral);
project model#target(targetName) {
to{ ... }
from { ... }
}
// Can be explicit with the type
project interface#target(targetName: StringLiteral) {
to{ ... }
from { ... }
}
The text was updated successfully, but these errors were encountered:
namespace Cadl;
projection target(targetName) {
model { ^ identifier
to { }
from { }
}
interface {
to {}
from {}
}
}
// another lib
use projection Cadl.target(targetName) {
MyModel { ^ reference
to {} from {}
}
}
Updated proposal taken from #928
Update to projection declaration
Separated in 3 steps that could be implemented one by one.
1. Projection name as symbol
Changes:
projection
keyword is used to declare the projection nameproject
keyword is used to declare a projection implementationEffect:
Usage of projection
2. Define arguments on the projection declaration
Change
Effect:
to
andfrom
MUST have the same arguments.3. Add typing to arguments
Changes:
Effect:
The text was updated successfully, but these errors were encountered: