Typescript.Definitions.Tool2
2.0.0
dotnet add package Typescript.Definitions.Tool2 --version 2.0.0
NuGet\Install-Package Typescript.Definitions.Tool2 -Version 2.0.0
<PackageReference Include="Typescript.Definitions.Tool2" Version="2.0.0" />
paket add Typescript.Definitions.Tool2 --version 2.0.0
#r "nuget: Typescript.Definitions.Tool2, 2.0.0"
// Install Typescript.Definitions.Tool2 as a Cake Addin #addin nuget:?package=Typescript.Definitions.Tool2&version=2.0.0 // Install Typescript.Definitions.Tool2 as a Cake Tool #tool nuget:?package=Typescript.Definitions.Tool2&version=2.0.0
Typescript.Definitions.Tools2
A helper library to generate typescript definition files and typescript files from c# code specifically .NET Core 2.0 Web applications.
This is a fork from this project, originally developed by originalmoose. Updated from .NET Core 1.0 to .NET Core 2.0.
This project took much of its inspiration from TypeLITE and the EntityFramework Core Tools project.
Installation
After creating a new .Net core 2.0 application add the following to dependecies and tools in .csproj
<PackageReference Include="Typescript.Definitions.Tools2" Version="2.0.0" />
and
<DotNetCliToolReference Include="Typescript.Definitions.Tools2" Version="2.0.0" />
After modifying the .csproj
file, execute the command dotnet restore
Create a new class and have it implement ITypedef
, example below.
public class Typedef : ITypedef
{
public void Configure(IDefinitionBuilder definitionBuilder)
{
/* Configure definitions here. */
}
}
Definition Configuration
Inside the ConfigureDefinitions method you can create any number of definiton files. There is only a single method on IDefinitionBuilder AddDefinition
you can use it like so.
definitionBuilder.AddDefinition(
def => def.For<ExampleClass>(optionalConfig => optionalConfig.Named("OverrideTypeName"))
.For(typeof(OtherClass))
.For(someAssemblyToScan)
//Use the following method to change the name of the definition and constants files that are generated.
.Filename(definitionFilename: "differentDefinitionName", constantsFilename: "differentConstantsName")
//Use the following method to change the outdir of the definition files, NOT YET IMPLEMENTED/TESTED MAY NOT WORK
.OutDir("C:\\SomeOtherDir")
)
Most of the methods are exactly the same as you would use in TypeLite. The only difference is the filename method, outdir method, and an optional parameter on the For
methods that allows you to configure the type. Typelite had you chaining off the For
to modify the type you just added it but I found the syntax for that to be confusing to read.
Assembly scanning works off of attributes, they are exactly the same (and should work the same) as TypeLite.
Once your project startup file is configured you can have the tool generate the definition files in one of two ways.
Manually execute the following from a cmd line in the Project Directory.
dotnet tsd2
Add the following to the Target
section of .csproj
(this should regenerate the definitions after each successful build)
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="dotnet tsd2 --no-build" />
</Target>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.0
- Microsoft.AspNetCore.All (>= 2.0.0)
- Microsoft.DotNet.Cli.Utils (>= 2.0.0)
- Microsoft.DotNet.Compiler.Common (>= 1.0.0-preview2-1-003177)
- Microsoft.DotNet.InternalAbstractions (>= 1.0.500-preview2-1-003177)
- Microsoft.DotNet.ProjectModel.Loader (>= 1.0.0-preview2-1-003177)
- Microsoft.Extensions.CommandLineUtils (>= 1.1.1)
- Microsoft.NETCore.App (>= 2.0.0)
- NuGet.Packaging.Core.Types (>= 4.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 2,078 | 10/24/2017 |
First update to .NET Core 2.0