├── cake
├── .gitignore
├── nuget.exe
└── .config
│ └── dotnet-tools.json
├── stuff
├── relnotes
│ ├── 1.5.1.md
│ ├── 1.6.2.md
│ ├── 1.6.3.md
│ ├── 1.6.4.md
│ ├── 1.6.6.md
│ ├── 1.6.7.md
│ ├── 1.4.97.md
│ ├── 1.5.6.md
│ ├── 1.6.1.md
│ ├── 1.5.4.md
│ ├── 1.6.5.md
│ ├── 1.5.2.md
│ ├── 1.5.3.md
│ ├── 1.5.7.md
│ ├── 1.5.8.md
│ ├── 1.5.9.md
│ ├── 1.6.0.md
│ ├── 1.4.96.md
│ └── 1.5.md
├── Reinforced.Typings.Multi.targets
├── readme.txt
└── license.txt
├── icon.png
├── Reinforced_pub.snk
├── Samples
├── Simple
│ └── Reinforced.Typings.Samples.Simple.Quickstart
│ │ ├── Scripts
│ │ ├── MyApplication
│ │ │ └── .gitignore
│ │ └── app
│ │ │ ├── Server.js.map
│ │ │ ├── Server.js
│ │ │ ├── Server.ts
│ │ │ ├── HomeIndex.ts
│ │ │ └── HomeIndex.js.map
│ │ ├── Views
│ │ ├── _ViewStart.cshtml
│ │ ├── Home
│ │ │ └── Index.cshtml
│ │ ├── Shared
│ │ │ └── _Layout.cshtml
│ │ └── web.config
│ │ ├── Global.asax
│ │ ├── Global.asax.cs
│ │ ├── Models
│ │ └── OrderViewModel.cs
│ │ ├── packages.config
│ │ ├── App_Start
│ │ └── RouteConfig.cs
│ │ ├── Controllers
│ │ └── HomeController.cs
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ └── Properties
│ │ └── AssemblyInfo.cs
├── Difficult
│ └── Reinforced.Typings.Samples.Difficult.CodeGenerators
│ │ ├── Views
│ │ └── _ViewStart.cshtml
│ │ ├── Scripts
│ │ ├── ReinforcedTypings
│ │ │ ├── app.ts
│ │ │ ├── app.js
│ │ │ ├── Generated
│ │ │ │ ├── models.js.map
│ │ │ │ ├── models.js
│ │ │ │ └── models.ts
│ │ │ ├── app.js.map
│ │ │ └── query.js.map
│ │ ├── _references.js
│ │ ├── version.json
│ │ ├── angular-csp.css
│ │ ├── angular-cookies.min.js
│ │ ├── angular-loader.min.js
│ │ └── typings
│ │ │ └── angularjs
│ │ │ └── angular-sanitize.d.ts
│ │ ├── Global.asax
│ │ ├── App_Start
│ │ ├── FilterConfig.cs
│ │ ├── RouteConfig.cs
│ │ └── BundleConfig.cs
│ │ ├── Startup.cs
│ │ ├── Controllers
│ │ └── HomeController.cs
│ │ ├── Global.asax.cs
│ │ ├── Content
│ │ ├── prismjs
│ │ │ ├── cshtml.css
│ │ │ └── cshtml.js
│ │ └── Site.css
│ │ ├── Models
│ │ └── SampleResponseModel.cs
│ │ ├── ReinforcedTypings
│ │ ├── Angular
│ │ │ └── AngularMethodAttribute.cs
│ │ ├── jQuery
│ │ │ └── JQueryMethodAttribute.cs
│ │ └── Configuration.cs
│ │ ├── Reinforced.Typings.settings.xml
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ └── Properties
│ │ └── AssemblyInfo.cs
└── Reinforced.Typings.Samples.sln
├── Reinforced.Typings
├── Sign.cs
├── Reinforced_pub.snk
├── ExportContext
│ ├── IWarningsCollector.cs
│ └── ExportContext.cs
├── Ast
│ ├── TypeNames
│ │ └── RtTypeName.cs
│ ├── IDecoratable.cs
│ ├── RtCompilationUnit.cs
│ ├── JsdocTagAttribute.cs
│ ├── RtNode.cs
│ ├── Dependency
│ │ └── RtReference.cs
│ ├── RtMember.cs
│ ├── ITypeMember.cs
│ ├── RtEnumValue.cs
│ ├── RtDecorator.cs
│ ├── RtJsdocNode.cs
│ ├── RtRaw.cs
│ └── RtIdentifier.cs
├── Xmldoc
│ └── Model
│ │ ├── DocumentationMemberType.cs
│ │ └── XmlIgnoreInner.cs
├── Attributes
│ ├── TsIgnoreAttribute.cs
│ ├── TsAttributeBase.cs
│ ├── TsEnumAttribute.cs
│ ├── TsValueAttribute.cs
│ ├── TsTypedAttributeBase.cs
│ ├── TsTypedMemberAttributeBase.cs
│ ├── TsParameterAttribute.cs
│ ├── TsFileAttribute.cs
│ ├── TsReferenceAttribute.cs
│ ├── TsDecoratorAttribute.cs
│ ├── IAutoexportSwitchAttribute.cs
│ ├── TsFunctionAttribute.cs
│ ├── TsGenericAttribute.cs
│ └── TsAddTypeReference.cs
├── Visitors
│ ├── TypeScript
│ │ ├── TypeScriptExportVisitor.RtIdentifier.cs
│ │ ├── TypeScriptExportVisitor.RtRaw.cs
│ │ ├── Types
│ │ │ ├── TypeScriptExportVisitor.RtArrayType.cs
│ │ │ ├── TypeScriptExportVisitor.RtTuple.cs
│ │ │ ├── TypeScriptExportVisitor.RtAsyncType.cs
│ │ │ ├── TypeScriptExportVisitor.RtDelegateType.cs
│ │ │ ├── TypeScriptExportVisitor.RtDictionaryType.cs
│ │ │ └── TypeScriptExportVisitor.RtSimpleTypeName.cs
│ │ ├── TypeScriptExportVisitor.RtEnumValue.cs
│ │ ├── TypeScriptExportVisitor.RtArgument.cs
│ │ ├── TypeScriptExportVisitor.RtField.cs
│ │ ├── TypeScriptExportVisitor.Dependencies.cs
│ │ ├── TypeScriptExportVisitor.RtInterface.cs
│ │ ├── TypeScriptExportVisitor.RtJsdocNode.cs
│ │ ├── TypeScriptExportVisitor.RtEnum.cs
│ │ ├── TypeScriptExportVisitor.RtConstructor.cs
│ │ ├── TypeScriptExportVisitor.RtNamespace.cs
│ │ ├── TypeScriptExportVisitor.RtClass.cs
│ │ └── TypeScriptExportVisitor.RtFunction.cs
│ └── Typings
│ │ ├── TypingsExportVisitor.cs
│ │ ├── TypingsExportVisitor.RtConstructor.cs
│ │ ├── TypingsExportVisitor.RtField.cs
│ │ ├── TypingsExportVisitor.RtModule.cs
│ │ ├── TypingsExportVisitor.RtFunction.cs
│ │ ├── TypingsExportVisitor.RtEnum.cs
│ │ └── TypingsExportVisitor.RtClass.cs
├── Fluent
│ ├── TypeBuilders
│ │ └── TypeExportBuilder.ThirdParty`1.cs
│ ├── MemberBuilders
│ │ ├── MemberExportBuilder.Field.cs
│ │ ├── MemberExportBuilder.Method.cs
│ │ ├── MemberExportBuilder.Property.cs
│ │ ├── MemberExportBuilder.cs
│ │ └── MemberExportBuilder.EnumValue.cs
│ ├── TypeExtensions
│ │ ├── TypeExportExtensions.Interface.cs
│ │ ├── TypeExportExtensions.All.NamesAndNamespaces.cs
│ │ └── TypeExportExtensions.Enum.cs
│ ├── MemberExtensions
│ │ ├── MemberExportExtensions.Parameter.cs
│ │ └── MemberExportExtensions.EnumValue.cs
│ └── Parameter.cs
├── AccessModifier.cs
├── ReferencesInspection
│ ├── ReferenceComparer.cs
│ ├── ImportComparer.cs
│ └── ReferenceProcessorBase.cs
├── Generators
│ ├── ITsCodeGenerator.cs
│ ├── FieldCodeGenerator.cs
│ ├── InterfaceCodeGenerator.cs
│ └── ClassCodeGenerator.cs
├── IFilesOperations.cs
├── Exceptions
│ ├── RtException.cs
│ └── RtWarning.cs
├── Reinforced.Typings.Dev.csproj
├── Reinforced.Typings.NETCore.csproj
└── Properties
│ └── AssemblyInfo.cs
├── Reinforced.Typings.Cli
├── app.config
├── Properties
│ ├── launchSettings.json
│ └── AssemblyInfo.cs
├── VisualStudioFriendlyMessageType.cs
├── ConsoleHelpAttribute.cs
└── Reinforced.Typings.Cli.Dev.csproj
├── TestFluentAssembly
├── TwoInterfaces.cs
├── TestFluentAssembly.Dev.csproj
├── TestFluentAssembly.NETCore.csproj
└── Properties
│ └── AssemblyInfo.cs
├── Reinforced.Typings.Tests
├── SpecificCases
│ ├── SpecificTestCases.All.cs
│ ├── SpecificTestCases.RluitenConstEnums.cs
│ ├── SpecificTestCases._CopyMe_.cs
│ ├── SpecificTestCases.JonsaCustomIndentationTest.cs
│ ├── SpecificTestCases.JonsaEnumWithouNamespaceTest.cs
│ ├── SpecificTestCases.ExportEnumsInDtsWithDeclareKeyword.cs
│ ├── SpecificTestCases.Records.cs
│ ├── SpecificTestCases.DtsNoDeclareEnumWithoutAmbientScope.cs
│ ├── SpecificTestCases.GenericsExport2.cs
│ ├── SpecificTestCases.PandaWoodCamelCase.cs
│ ├── SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs
│ ├── SpecificTestCases.ExportOrderTest1.cs
│ ├── SpecificTestCases.NvirthMultilineString.cs
│ ├── SpecificTestCases.FunctionalNames.cs
│ ├── SpecifiicTestCases.UnresolvedToUnknown.cs
│ ├── SpecificTestCases.Fields.cs
│ ├── SpecificTestCases.PandaWoodForceNullableTest.cs
│ ├── SpecificTestCases.EnumKeyedDictionary.cs
│ ├── SpecificTestCases.WeirdInheritanceCase.cs
│ ├── SpecificTestCases.ExportOrderTest2.cs
│ ├── SpecificTestCases.ExportEnums.cs
│ ├── SpecificTestCases.EnumStringInitializers.cs
│ ├── SpecificTestCases.HierarchyFlattening4.cs
│ ├── SpecificTestCases.GenericGuidDictionary.cs
│ ├── SpecificTestCases.InlineFunctionImplementation.cs
│ ├── SpecificTestCases.AutoOptional.cs
│ ├── SpecificTestCases.DecoratorsTest.cs
│ ├── SpecificTestCases.OverrideNamespaceWithModules.cs
│ ├── SpecificTestCases.NewForceNullable.cs
│ ├── SpecificTestCases.DaggmanoAutoIBug.cs
│ ├── SpecificTestCases.DocumentationForNestedTypes.cs
│ ├── SpecificTestCases.NewLineTest.cs
│ ├── SpecificTestCases.OverridenNamesNotCamelCased.cs
│ ├── SpecificTestCases.NestedClassInheritance.cs
│ ├── SpecificTestCases.GenericsExport3.cs
│ ├── SpecificTestCases.ReferencesPart6ByDanielWest.cs
│ └── SpecificTestCases.CrozinSubstitutions.cs
├── packages.config
├── Properties
│ └── AssemblyInfo.cs
└── Reinforced.Typings.Tests.Dev.csproj
├── Reinforced.Typings.Integrate
├── packages.config
└── Properties
│ └── AssemblyInfo.cs
└── LICENSE.md
/cake/.gitignore:
--------------------------------------------------------------------------------
1 | tools/
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.1.md:
--------------------------------------------------------------------------------
1 | - MacOS/Linux fixes
--------------------------------------------------------------------------------
/stuff/relnotes/1.6.2.md:
--------------------------------------------------------------------------------
1 | - .NET 7 Support
--------------------------------------------------------------------------------
/stuff/relnotes/1.6.3.md:
--------------------------------------------------------------------------------
1 | - .NET 8 Support
--------------------------------------------------------------------------------
/stuff/relnotes/1.6.4.md:
--------------------------------------------------------------------------------
1 | - .NET 9 Support
--------------------------------------------------------------------------------
/stuff/relnotes/1.6.6.md:
--------------------------------------------------------------------------------
1 | - .NET 10 Support
--------------------------------------------------------------------------------
/stuff/relnotes/1.6.7.md:
--------------------------------------------------------------------------------
1 | - .NET 10 Support
--------------------------------------------------------------------------------
/stuff/relnotes/1.4.97.md:
--------------------------------------------------------------------------------
1 | - MSBuild behavior fixes
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.6.md:
--------------------------------------------------------------------------------
1 | - Support for .NET Core 3.1
--------------------------------------------------------------------------------
/stuff/relnotes/1.6.1.md:
--------------------------------------------------------------------------------
1 | - Warnings suppression quickfix
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.4.md:
--------------------------------------------------------------------------------
1 | - .NET Core 3.0 Support
2 | - Bugfixes
--------------------------------------------------------------------------------
/stuff/relnotes/1.6.5.md:
--------------------------------------------------------------------------------
1 | - Fix for malformed package of .NET 9 Support
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.2.md:
--------------------------------------------------------------------------------
1 | - Documentation lookup bugfixes
2 | - Visitor overrides
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.3.md:
--------------------------------------------------------------------------------
1 | - fix bug #125
2 | - fix bug #119
3 | - fix bug #114
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reinforced/Reinforced.Typings/HEAD/icon.png
--------------------------------------------------------------------------------
/cake/nuget.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reinforced/Reinforced.Typings/HEAD/cake/nuget.exe
--------------------------------------------------------------------------------
/Reinforced_pub.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reinforced/Reinforced.Typings/HEAD/Reinforced_pub.snk
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Scripts/MyApplication/.gitignore:
--------------------------------------------------------------------------------
1 | *.ts
2 |
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.7.md:
--------------------------------------------------------------------------------
1 | - Assembly Regex (partial fix for .net framework 3.1.1 and upcoming versions)
--------------------------------------------------------------------------------
/Reinforced.Typings/Sign.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyKeyFile("Reinforced.snk")]
4 |
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.8.md:
--------------------------------------------------------------------------------
1 | - PR #178
2 | - PR #177
3 | - PR #176
4 | - PR #164
5 | - Fix typo in "RtFuncion"
6 | - AutoAsync feature
7 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Reinforced_pub.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reinforced/Reinforced.Typings/HEAD/Reinforced.Typings/Reinforced_pub.snk
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "~/Views/Shared/_Layout.cshtml";
3 | }
4 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "~/Views/Shared/_Layout.cshtml";
3 | }
4 |
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.9.md:
--------------------------------------------------------------------------------
1 | - PR #188 - Support of .NET 5
2 | - PR #187 - Support of C#8 nullables
3 | - PR #183 - RtAsync and more efficiend promists handling
4 | - build fixes
5 |
--------------------------------------------------------------------------------
/stuff/relnotes/1.6.0.md:
--------------------------------------------------------------------------------
1 | - PR #222 - Support of .NET 6
2 | - Fixed unit tests
3 | - Equality comparers for AST nodes
4 | - Warnings suppression (RtSuppress in settings.xml)
5 |
--------------------------------------------------------------------------------
/stuff/Reinforced.Typings.Multi.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Cli/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/ReinforcedTypings/app.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | var app = angular.module('app', []);
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="Reinforced.Typings.Samples.Simple.Quickstart.MvcApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Scripts/app/Server.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"Server.js","sourceRoot":"","sources":["Server.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,4EAA4E;AAC5E,+BAA+B"}
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="Reinforced.Typings.Samples.Difficult.CodeGenerators.MvcApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/ReinforcedTypings/app.js:
--------------------------------------------------------------------------------
1 | ///
2 | var app = angular.module('app', []);
3 | //# sourceMappingURL=app.js.map
--------------------------------------------------------------------------------
/stuff/relnotes/1.4.96.md:
--------------------------------------------------------------------------------
1 | - .NET Core 2.2 support
2 | - Moved builds to Cake
3 | - #92 Setting changes are not respected within Visual Studio until restart - fixed
4 | - For better flexibility added RtForceTargetFramework configuration setting
--------------------------------------------------------------------------------
/stuff/relnotes/1.5.md:
--------------------------------------------------------------------------------
1 | - MSBuild behavior fixes
2 | - ReferenceProcessor
3 | - ReorderMembers
4 | - ThirdParty attribute
5 | - Fluent configuration refactoring
6 | - Constructors generation
7 | - ForceNullable behavior revised
8 | - Lots of bugfixes
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/ReinforcedTypings/Generated/models.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"models.js","sourceRoot":"","sources":["models.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,4EAA4E;AAC5E,+BAA+B"}
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/_references.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/reinforced/Reinforced.Typings/HEAD/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/_references.js
--------------------------------------------------------------------------------
/Reinforced.Typings/ExportContext/IWarningsCollector.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Exceptions;
2 |
3 | namespace Reinforced.Typings
4 | {
5 | internal interface IWarningsCollector
6 | {
7 | void AddWarning(RtWarning warning);
8 | }
9 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Cli/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Reinforced.Typings.Cli.NETCore": {
4 | "commandName": "Project",
5 | "commandLineArgs": "profile \"w:\\Work\\Reinforced\\Typings\\testfile.txt\""
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/ReinforcedTypings/app.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAEzD,IAAI,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC"}
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/TypeNames/RtTypeName.cs:
--------------------------------------------------------------------------------
1 | namespace Reinforced.Typings.Ast.TypeNames
2 | {
3 | ///
4 | /// Abstract AST node for type name
5 | ///
6 | public abstract class RtTypeName : RtNode
7 | {
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/cake/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "isRoot": true,
4 | "tools": {
5 | "cake.tool": {
6 | "version": "5.0.0",
7 | "commands": [
8 | "dotnet-cake"
9 | ],
10 | "rollForward": false
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Scripts/app/Server.js:
--------------------------------------------------------------------------------
1 | // This code was generated by a Reinforced.Typings tool.
2 | // Changes to this file may cause incorrect behavior and will be lost if
3 | // the code is regenerated.
4 | //# sourceMappingURL=Server.js.map
--------------------------------------------------------------------------------
/TestFluentAssembly/TwoInterfaces.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace TestFluentAssembly.TwoInterfaces
4 | {
5 | public interface IInterface1
6 | {
7 | IInterface2 Iface2 { get; }
8 | }
9 |
10 | public interface IInterface2
11 | {
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/ReinforcedTypings/Generated/models.js:
--------------------------------------------------------------------------------
1 | // This code was generated by a Reinforced.Typings tool.
2 | // Changes to this file may cause incorrect behavior and will be lost if
3 | // the code is regenerated.
4 | //# sourceMappingURL=models.js.map
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Views/Home/Index.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | @section Scripts{
6 |
7 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Cli/VisualStudioFriendlyMessageType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Reinforced.Typings.Cli
8 | {
9 | public enum VisualStudioFriendlyMessageType
10 | {
11 | Error,
12 | Warning
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/version.json:
--------------------------------------------------------------------------------
1 | {"raw":"v1.4.8","major":1,"minor":4,"patch":8,"prerelease":[],"build":[],"version":"1.4.8","codeName":"ice-manipulation","full":"1.4.8","branch":"v1.4.x","cdn":{"raw":"v1.4.7","major":1,"minor":4,"patch":7,"prerelease":[],"build":[],"version":"1.4.7","docsUrl":"http://code.angularjs.org/1.4.7/docs"}}
--------------------------------------------------------------------------------
/Reinforced.Typings/Xmldoc/Model/DocumentationMemberType.cs:
--------------------------------------------------------------------------------
1 |
2 | #pragma warning disable 1591
3 |
4 | namespace Reinforced.Typings.Xmldoc.Model
5 | {
6 | public enum DocumentationMemberType
7 | {
8 | Type,
9 | Property,
10 | Field,
11 | Event,
12 | Namespace,
13 | Method,
14 | Constructor,
15 | Unknown
16 | }
17 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/IDecoratable.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Reinforced.Typings.Ast
4 | {
5 | ///
6 | /// Node containing decorators
7 | ///
8 | public interface IDecoratable
9 | {
10 | ///
11 | /// Set of decorators applied to node
12 | ///
13 | List Decorators { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/App_Start/FilterConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 |
3 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators
4 | {
5 | public class FilterConfig
6 | {
7 | public static void RegisterGlobalFilters(GlobalFilterCollection filters)
8 | {
9 | filters.Add(new HandleErrorAttribute());
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/TestFluentAssembly/TestFluentAssembly.Dev.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 | TestFluentAssembly
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Owin;
2 | using Owin;
3 |
4 | [assembly: OwinStartupAttribute(typeof(Reinforced.Typings.Samples.Difficult.CodeGenerators.Startup))]
5 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators
6 | {
7 | public partial class Startup
8 | {
9 | public void Configuration(IAppBuilder app)
10 | {
11 |
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.All.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Reinforced.Typings.Cli;
4 | using Reinforced.Typings.Fluent;
5 | using Reinforced.Typings.ReferencesInspection;
6 | using Reinforced.Typings.Tests.Core;
7 | using Xunit;
8 |
9 | namespace Reinforced.Typings.Tests.SpecificCases
10 | {
11 | public partial class SpecificTestCases : RtExporterTestBase
12 | {
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsIgnoreAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Attributes
4 | {
5 | ///
6 | /// Instructs DynTyping do not to export mentioned member
7 | ///
8 | [AttributeUsage(
9 | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Parameter |
10 | AttributeTargets.Constructor)]
11 | public class TsIgnoreAttribute : Attribute
12 | {
13 | }
14 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtIdentifier.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | public override void Visit(RtIdentifier node)
8 | {
9 | if (node == null) return;
10 | Write(node.IdentifierName);
11 | if (node.IsNullable) Write("?");
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Reinforced.Typings Test Application
7 |
8 | @RenderSection("Scripts", required: false)
9 |
10 |
11 |
12 | @RenderBody()
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Fluent/TypeBuilders/TypeExportBuilder.ThirdParty`1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 |
4 | namespace Reinforced.Typings.Fluent
5 | {
6 | ///
7 | /// Fluent export configuration builder for class (generic)
8 | ///
9 | public class ThirdPartyExportBuilder : ThirdPartyExportBuilder
10 | {
11 | internal ThirdPartyExportBuilder(TypeBlueprint blueprint) : base(blueprint)
12 | {
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtRaw.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | public override void Visit(RtRaw node)
8 | {
9 | if (node == null) return;
10 | if (string.IsNullOrEmpty(node.RawContent)) return;
11 | WriteLines(node.RawContent);
12 | }
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/angular-csp.css:
--------------------------------------------------------------------------------
1 | /* Include this file in your html if you are using the CSP mode. */
2 |
3 | @charset "UTF-8";
4 |
5 | [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak],
6 | .ng-cloak, .x-ng-cloak,
7 | .ng-hide:not(.ng-hide-animate) {
8 | display: none !important;
9 | }
10 |
11 | ng\:form {
12 | display: block;
13 | }
14 |
15 | .ng-animate-shim {
16 | visibility:hidden;
17 | }
18 |
19 | .ng-anchor {
20 | position:absolute;
21 | }
22 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsAttributeBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Attributes
4 | {
5 | ///
6 | /// Base for all attributes
7 | ///
8 | public abstract class TsAttributeBase : Attribute
9 | {
10 | ///
11 | /// Dummy function body generator
12 | /// If empty then it's being generated empty/return null body.
13 | ///
14 | public virtual Type CodeGeneratorType { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Scripts/app/Server.ts:
--------------------------------------------------------------------------------
1 | // This code was generated by a Reinforced.Typings tool.
2 | // Changes to this file may cause incorrect behavior and will be lost if
3 | // the code is regenerated.
4 |
5 | module Reinforced.Typings.Samples.Simple.Quickstart.Models {
6 | export interface IOrderViewModel
7 | {
8 | ItemName: string;
9 | Quantity: number;
10 | Subtotal: number;
11 | IsPaid: boolean;
12 | ClientName: string;
13 | Address: string;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/Types/TypeScriptExportVisitor.RtArrayType.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast.TypeNames;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | #region Types
8 |
9 | public override void Visit(RtArrayType node)
10 | {
11 | if (node == null) return;
12 | Visit(node.ElementType);
13 | Write("[]");
14 | }
15 |
16 | #endregion
17 | }
18 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/AccessModifier.cs:
--------------------------------------------------------------------------------
1 | namespace Reinforced.Typings
2 | {
3 | ///
4 | /// Represents member's access modifier
5 | ///
6 | public enum AccessModifier
7 | {
8 | ///
9 | /// private
10 | ///
11 | Private,
12 |
13 | ///
14 | /// protected
15 | ///
16 | Protected,
17 |
18 | ///
19 | /// public
20 | ///
21 | Public
22 | }
23 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/Types/TypeScriptExportVisitor.RtTuple.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast.TypeNames;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | #region Types
8 | public override void Visit(RtTuple node)
9 | {
10 | if (node==null) return;
11 | Write("[");
12 | SequentialVisit(node.TupleTypes,",");
13 | Write("]");
14 | }
15 |
16 |
17 | #endregion
18 |
19 |
20 | }
21 | }
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Mvc;
6 | using System.Web.Routing;
7 |
8 | namespace Reinforced.Typings.Samples.Simple.Quickstart
9 | {
10 | public class MvcApplication : System.Web.HttpApplication
11 | {
12 |
13 | protected void Application_Start()
14 | {
15 | AreaRegistration.RegisterAllAreas();
16 | RouteConfig.RegisterRoutes(RouteTable.Routes);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 |
3 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators.Controllers
4 | {
5 | public class HomeController : Controller
6 | {
7 | public ActionResult Index()
8 | {
9 | return View();
10 | }
11 |
12 | public ActionResult JQuery()
13 | {
14 | return View();
15 | }
16 |
17 | public ActionResult Angular()
18 | {
19 | return View();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/Types/TypeScriptExportVisitor.RtAsyncType.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast.TypeNames;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | #region Types
8 |
9 | public override void Visit(RtAsyncType node)
10 | {
11 | Write("Promise<");
12 |
13 | if (node.TypeNameOfAsync != null) this.Visit(node.TypeNameOfAsync);
14 | else Write("void");
15 |
16 | Write(">");
17 | }
18 |
19 | #endregion
20 | }
21 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Integrate/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/Types/TypeScriptExportVisitor.RtDelegateType.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast.TypeNames;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | #region Types
8 |
9 | public override void Visit(RtDelegateType node)
10 | {
11 | if (node == null) return;
12 | Write("(");
13 | SequentialVisit(node.Arguments, ", ");
14 | Write(") => ");
15 | Visit(node.Result);
16 | }
17 |
18 | #endregion
19 | }
20 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Xmldoc/Model/XmlIgnoreInner.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 | using System.Xml.Schema;
4 | using System.Xml.Serialization;
5 |
6 | #pragma warning disable 1591
7 |
8 | namespace Reinforced.Typings.Xmldoc.Model
9 | {
10 | public abstract class XmlIgnoreInner : IXmlSerializable
11 | {
12 | public XmlSchema GetSchema()
13 | {
14 | throw new NotImplementedException();
15 | }
16 |
17 | public abstract void ReadXml(XmlReader reader);
18 |
19 | public void WriteXml(XmlWriter writer)
20 | {
21 | throw new NotImplementedException();
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/ReinforcedTypings/Generated/models.ts:
--------------------------------------------------------------------------------
1 | // This code was generated by a Reinforced.Typings tool.
2 | // Changes to this file may cause incorrect behavior and will be lost if
3 | // the code is regenerated.
4 |
5 | module Reinforced.Typings.Samples.Difficult.CodeGenerators.Models {
6 | /** Sample model that we will use for tests */
7 | export interface ISampleResponseModel
8 | {
9 | /** String property - message */
10 | Message: string;
11 | /** Boolean flag */
12 | Success: boolean;
13 | /** String containing date */
14 | CurrentTime: string;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 | using System.Web.Optimization;
3 | using System.Web.Routing;
4 |
5 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators
6 | {
7 | public class MvcApplication : System.Web.HttpApplication
8 | {
9 | protected void Application_Start()
10 | {
11 | AreaRegistration.RegisterAllAreas();
12 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
13 | RouteConfig.RegisterRoutes(RouteTable.Routes);
14 | BundleConfig.RegisterBundles(BundleTable.Bundles);
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Models/OrderViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 |
6 | namespace Reinforced.Typings.Samples.Simple.Quickstart.Models
7 | {
8 | using Reinforced.Typings.Attributes;
9 |
10 | [TsInterface]
11 | public class OrderViewModel
12 | {
13 | public string ItemName { get; set; }
14 | public int Quantity { get; set; }
15 | public double Subtotal { get; set; }
16 | public bool IsPaid { get; set; }
17 | public string ClientName { get; set; }
18 | public string Address { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtEnumValue.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | public override void Visit(RtEnumValue node)
8 | {
9 | if (node == null) return;
10 | Visit(node.Documentation);
11 | AppendTabs();
12 | Write(node.EnumValueName);
13 | if (!string.IsNullOrEmpty(node.EnumValue))
14 | {
15 | Write(" = ");
16 | Write(node.EnumValue);
17 | }
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.RluitenConstEnums.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void RluitenConstEnums()
10 | {
11 | const string result = @"
12 | export const enum SomeEnum {
13 | One = 0,
14 | Two = 1
15 | }";
16 | AssertConfiguration(s =>
17 | {
18 | s.Global(a => a.DontWriteWarningComment().UseModules());
19 | s.ExportAsEnum().Const();
20 | }, result);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/App_Start/RouteConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web.Mvc;
2 | using System.Web.Routing;
3 |
4 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators
5 | {
6 | public class RouteConfig
7 | {
8 | public static void RegisterRoutes(RouteCollection routes)
9 | {
10 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
11 |
12 | routes.MapRoute(
13 | name: "Default",
14 | url: "{controller}/{action}/{id}",
15 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
16 | );
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Content/prismjs/cshtml.css:
--------------------------------------------------------------------------------
1 | .razor_comment{
2 | color:#53c175;;
3 | }
4 | .razor_comment_begin{
5 | color: darkgreen;
6 | }
7 | .razor_comment_end{
8 | color: darkgreen;
9 | }
10 | .razor_pageclass{
11 | color:#00cf8c
12 | }
13 | .razor_inline_key {
14 | color:#00cf8c;
15 | }
16 | .razor_borders{
17 | background-color: #e8e86f;
18 | color:black;
19 | }
20 | .razor_block {
21 | background-color:#535645;
22 | }
23 | .razor_inline_method{
24 | color:#7ee895;
25 | }
26 | .razor_inline{
27 | background-color:#535645;
28 | }
29 | .razor_keyword{
30 | background-color: #41412b;
31 | color:#7895ff;
32 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsEnumAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Attributes
4 | {
5 | ///
6 | /// Exports enum as TypeScript Enum
7 | ///
8 | [AttributeUsage(AttributeTargets.Enum)]
9 | public class TsEnumAttribute : TsDeclarationAttributeBase
10 | {
11 | ///
12 | /// When true, results "const" enum instead of usual
13 | ///
14 | public bool IsConst { get; set; }
15 |
16 | ///
17 | /// Gets or sets whetner enum fields must be exported with string initializers (TypeScript 2.4)
18 | ///
19 | public bool UseString { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/RtCompilationUnit.cs:
--------------------------------------------------------------------------------
1 | namespace Reinforced.Typings.Ast
2 | {
3 | ///
4 | /// Abstract AST node for class/interface/enum
5 | ///
6 | public abstract class RtCompilationUnit : RtNode
7 | {
8 | ///
9 | /// Denotes current class to be exported
10 | ///
11 | public bool Export { get; set; }
12 |
13 | ///
14 | /// Denotes that current class must be default export of module
15 | ///
16 | public bool DefaultExport { get; set; }
17 |
18 | ///
19 | /// Order of writing
20 | ///
21 | public double Order { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/JsdocTagAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Ast
4 | {
5 | ///
6 | /// JSDOC tag attribute to convert enum name back to JSDOC tag
7 | ///
8 | internal class JsdocTagAttribute : Attribute
9 | {
10 | ///
11 | /// Raw tag name
12 | ///
13 | public string RawTagName { get; set; }
14 |
15 | ///
16 | /// Constructs new instance of JsdicTag attribute
17 | ///
18 | /// Raw tag name
19 | public JsdocTagAttribute(string rawTagName)
20 | {
21 | RawTagName = rawTagName;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/Types/TypeScriptExportVisitor.RtDictionaryType.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast.TypeNames;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | #region Types
8 |
9 | public override void Visit(RtDictionaryType node)
10 | {
11 | if (node == null) return;
12 | string keyTypeSpec = node.IsKeyEnum ? " in " : ":";
13 | Write("{ [key");
14 | Write(keyTypeSpec);
15 | Visit(node.KeyType);
16 | Write("]: ");
17 | Visit(node.ValueType);
18 | Write(" }");
19 | }
20 |
21 | #endregion
22 | }
23 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/Typings/TypingsExportVisitor.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using Reinforced.Typings.Ast;
3 | using Reinforced.Typings.Visitors.TypeScript;
4 | #pragma warning disable 1591
5 | namespace Reinforced.Typings.Visitors.Typings
6 | {
7 | ///
8 | /// Visitor that is generating .d.ts from existing model
9 | ///
10 | public partial class TypingsExportVisitor : TypeScriptExportVisitor
11 | {
12 | public override void Visit(RtDecorator node)
13 | {
14 | //no decorators allowed in the .d.ts
15 | }
16 |
17 |
18 | public TypingsExportVisitor(TextWriter writer, ExportContext exportContext) : base(writer, exportContext)
19 | {
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Models/SampleResponseModel.cs:
--------------------------------------------------------------------------------
1 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators.Models
2 | {
3 | ///
4 | /// Sample model that we will use for tests
5 | ///
6 | public class SampleResponseModel
7 | {
8 | ///
9 | /// String property - message
10 | ///
11 | public string Message { get; set; }
12 |
13 | ///
14 | /// Boolean flag
15 | ///
16 | public bool Success { get; set; }
17 |
18 | ///
19 | /// String containing date
20 | ///
21 | public string CurrentTime { get; set; }
22 | }
23 |
24 |
25 |
26 | }
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/App_Start/RouteConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Mvc;
6 | using System.Web.Routing;
7 |
8 | namespace Reinforced.Typings.Samples.Simple.Quickstart
9 | {
10 | public class RouteConfig
11 | {
12 | public static void RegisterRoutes(RouteCollection routes)
13 | {
14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15 |
16 | routes.MapRoute(
17 | name: "Default",
18 | url: "{controller}/{action}/{id}",
19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20 | );
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Reinforced.Typings/ReferencesInspection/ReferenceComparer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Reinforced.Typings.Ast.Dependency;
3 |
4 | namespace Reinforced.Typings.ReferencesInspection
5 | {
6 | sealed class ReferenceComparer : IEqualityComparer
7 | {
8 | public bool Equals(RtReference x, RtReference y)
9 | {
10 | return x.Path == y.Path;
11 | }
12 |
13 | public int GetHashCode(RtReference obj)
14 | {
15 | return obj.Path.GetHashCode();
16 | }
17 |
18 | private static readonly ReferenceComparer _instance = new ReferenceComparer();
19 |
20 | public static ReferenceComparer Instance
21 | {
22 | get { return _instance; }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Cli/ConsoleHelpAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Cli
4 | {
5 | ///
6 | /// Denotes console help for parameter
7 | ///
8 | public class ConsoleHelpAttribute : Attribute
9 | {
10 | ///
11 | /// Help text
12 | ///
13 | public string HelpText { get; set; }
14 |
15 | public Required RequiredType { get; set; }
16 |
17 |
18 | public ConsoleHelpAttribute(string helpText,Required requiredType = Required.Not)
19 | {
20 | HelpText = helpText;
21 | RequiredType = requiredType;
22 | }
23 | }
24 |
25 | public enum Required
26 | {
27 | Is,
28 | Not,
29 | Partially
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsValueAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Attributes
4 | {
5 | ///
6 | /// Specifies exporting enum value
7 | ///
8 | [AttributeUsage(AttributeTargets.Field)]
9 | public class TsValueAttribute : TsAttributeBase
10 | {
11 | ///
12 | /// Overrides enum value name
13 | ///
14 | public virtual string Name { get; set; }
15 |
16 | ///
17 | /// Overrides enum value's string initializer. This property works only if there is property set to true.
18 | /// Please escape quotes manually.
19 | ///
20 | public string Initializer { get; set; }
21 | }
22 | }
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Content/Site.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 50px;
3 | padding-bottom: 20px;
4 | }
5 |
6 | /* Set padding to keep content from hitting the edges */
7 | .body-content {
8 | padding-left: 15px;
9 | padding-right: 15px;
10 | }
11 |
12 | /* Override the default bootstrap behavior where horizontal description lists
13 | will truncate terms that are too long to fit in the left column
14 | */
15 | .dl-horizontal dt {
16 | white-space: normal;
17 | }
18 |
19 | /* Set width on the form input elements since they're 100% wide by default */
20 | input,
21 | select,
22 | textarea {
23 | max-width: 280px;
24 | }
25 |
26 |
27 | .spin {
28 | -webkit-animation: 2s infinite linear;
29 | animation: 2s infinite linear;
30 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases._CopyMe_.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Reinforced.Typings.Fluent;
3 | using Xunit;
4 |
5 | namespace Reinforced.Typings.Tests.SpecificCases
6 | {
7 |
8 | public partial class SpecificTestCases
9 | {
10 | [Fact]
11 | public void InterfaceAsInterface()
12 | {
13 | const string result = @"
14 | module Reinforced.Typings.Tests.SpecificCases {
15 | export interface ITestInterface
16 | {
17 | String: string;
18 | Int: number;
19 | }
20 | }";
21 | AssertConfiguration(s =>
22 | {
23 | s.Global(a => a.DontWriteWarningComment());
24 | s.ExportAsInterface().WithPublicProperties();
25 | }, result);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.JonsaCustomIndentationTest.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void JonsaCustomIndentationTest()
10 | {
11 | const string result = @"
12 | module Reinforced.Typings.Tests.SpecificCases {
13 | #export interface ITestInterface
14 | #{
15 | ##Int: number;
16 | ##String: string;
17 | #}
18 | }";
19 | AssertConfiguration(s =>
20 | {
21 | s.Global(a => a.DontWriteWarningComment().TabSymbol("#").ReorderMembers());
22 | s.ExportAsInterface().WithPublicProperties();
23 | }, result);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/Types/TypeScriptExportVisitor.RtSimpleTypeName.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast.TypeNames;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | #region Types
8 |
9 | public override void Visit(RtSimpleTypeName node)
10 | {
11 | if (node.HasPrefix)
12 | {
13 | Write(node.Prefix);
14 | Write(".");
15 | }
16 | Write(node.TypeName);
17 | if (node.GenericArguments.Length > 0)
18 | {
19 | Write("<");
20 | SequentialVisit(node.GenericArguments, ", ");
21 | Write(">");
22 | }
23 | }
24 |
25 | #endregion
26 | }
27 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.JonsaEnumWithouNamespaceTest.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void JonsaEnumWithouNamespaceTest()
10 | {
11 | const string result = @"
12 | interface IJonsaModel
13 | {
14 | Enum: JonsaEnum;
15 | }
16 | enum JonsaEnum {
17 | Foo = 0,
18 | Bar = 1
19 | }";
20 | AssertConfiguration(s =>
21 | {
22 | s.Global(a => a.DontWriteWarningComment());
23 | s.ExportAsInterface().WithPublicProperties().DontIncludeToNamespace();
24 | s.ExportAsEnum().DontIncludeToNamespace();
25 | }, result);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Fluent/MemberBuilders/MemberExportBuilder.Field.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | // ReSharper disable CheckNamespace
3 |
4 | namespace Reinforced.Typings.Fluent
5 | {
6 | ///
7 | /// Fluent export configuration builder for a field
8 | ///
9 | public class FieldExportBuilder : PropertyExportBuilder
10 | {
11 | /// Initializes a new instance of the class.
12 | internal FieldExportBuilder(TypeBlueprint containingTypeBlueprint, MemberInfo member) : base(containingTypeBlueprint, member)
13 | {
14 | }
15 |
16 | ///
17 | /// Gets property being configured
18 | ///
19 | public new FieldInfo Member
20 | {
21 | get { return (FieldInfo) _member; }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/RtNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Reinforced.Typings.Ast
4 | {
5 | ///
6 | /// Base Reinforced.Typings AST node
7 | ///
8 | public abstract class RtNode
9 | {
10 | ///
11 | /// Child nodes
12 | ///
13 | public abstract IEnumerable Children { get; }
14 |
15 | ///
16 | /// Visitor acceptance
17 | ///
18 | /// Visitor
19 | public abstract void Accept(IRtVisitor visitor);
20 |
21 | ///
22 | /// Typed visitor acceptance
23 | ///
24 | /// Visitor
25 | public abstract void Accept(IRtVisitor visitor);
26 |
27 | internal double _order;
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsTypedAttributeBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Attributes
4 | {
5 | ///
6 | /// Base attribute for typed members/parameters
7 | ///
8 | public abstract class TsTypedAttributeBase : TsAttributeBase
9 | {
10 | ///
11 | /// Overrides member type name in resulting TypeScript.
12 | /// Supplied as string. Helpful when property type is not present in your project.
13 | /// E.g. - JQquery object.
14 | ///
15 | public virtual string Type { get; set; }
16 |
17 | ///
18 | /// Similar to `Type`, but you can specify .NET type using typeof.
19 | /// It is useful e.g. for delegates
20 | ///
21 | public virtual Type StrongType { get; set; }
22 |
23 | }
24 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.ExportEnumsInDtsWithDeclareKeyword.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void ExportEnumsInDtsWithDeclareKeyword()
10 | {
11 | const string result = @"
12 | declare module Reinforced.Typings.Tests.SpecificCases {
13 | export enum TestEnum1 {
14 | A = 0,
15 | B = 1,
16 | C = 2
17 | }
18 | export enum TestEnum2 {
19 | C = 0,
20 | D = 1,
21 | E = 2
22 | }
23 | }";
24 | AssertConfiguration(s =>
25 | {
26 | s.Global(a => a.DontWriteWarningComment().ExportPureTypings());
27 | s.ExportAsEnums(new[] { typeof(TestEnum1), typeof(TestEnum2) });
28 | }, result);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsTypedMemberAttributeBase.cs:
--------------------------------------------------------------------------------
1 | namespace Reinforced.Typings.Attributes
2 | {
3 | ///
4 | /// Base attribute for class members and method parameters
5 | ///
6 | public abstract class TsTypedMemberAttributeBase : TsTypedAttributeBase
7 | {
8 | ///
9 | /// When true them member name will be camelCased regardless configuration setting
10 | ///
11 | public bool ShouldBeCamelCased { get; set; }
12 |
13 | ///
14 | /// When true them member name will be PascalCased regardless configuration setting
15 | ///
16 | public bool ShouldBePascalCased { get; set; }
17 |
18 | ///
19 | /// Overrides member name
20 | ///
21 | public virtual string Name { get; set; }
22 |
23 |
24 | }
25 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.Records.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Reinforced.Typings.Fluent;
3 | using Xunit;
4 |
5 | namespace Reinforced.Typings.Tests.SpecificCases
6 | {
7 | public record Person(string FirstName, string LastName);
8 |
9 |
10 | public partial class SpecificTestCases
11 | {
12 | [Fact]
13 | public void Records()
14 | {
15 | const string result = @"
16 | module Reinforced.Typings.Tests.SpecificCases {
17 | export interface IPerson
18 | {
19 | FirstName: string;
20 | LastName: string;
21 | }
22 | }";
23 |
24 | AssertConfiguration(s =>
25 | {
26 | s.Global(a => a.DontWriteWarningComment());
27 | s.ExportAsInterface().WithPublicProperties();
28 | }, result);
29 |
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.DtsNoDeclareEnumWithoutAmbientScope.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Enum.Test
5 | {
6 | public enum Version
7 | {
8 | Current = 1
9 | }
10 | }
11 |
12 | namespace Reinforced.Typings.Tests.SpecificCases
13 | {
14 | public partial class SpecificTestCases
15 | {
16 | [Fact]
17 | public void DtsNoDeclareEnumWithoutAmbientScope()
18 | {
19 | const string result = @"
20 | declare module Enum.Test {
21 | export const enum Version {
22 | Current = 1
23 | }
24 | }";
25 | AssertConfiguration(s =>
26 | {
27 | s.Global(a => a.DontWriteWarningComment().UseModules(false, false)
28 | .ExportPureTypings(true));
29 | s.ExportAsEnum().Const();
30 | }, result);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.GenericsExport2.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | class GenericModel
7 | {
8 |
9 | }
10 | public partial class SpecificTestCases
11 | {
12 | [Fact]
13 | public void GenericsExport2()
14 | {
15 | const string result = @"
16 | export class GenericModel
17 | {
18 | }
19 | ";
20 |
21 | AssertConfiguration(s =>
22 | {
23 | s.Global(a => a.DontWriteWarningComment().UseModules());
24 | s.ExportAsClasses(new[]
25 | {
26 | typeof(GenericModel<>)
27 | }, x => x.DontIncludeToNamespace().WithPublicProperties().WithPublicMethods());
28 |
29 | }, result);
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.PandaWoodCamelCase.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void PandaWoodCamelCase()
10 | {
11 | const string result = @"
12 | module Reinforced.Typings.Tests.SpecificCases {
13 | export interface IPandaWoodCamelCaseTest
14 | {
15 | id: number;
16 | eta() : void;
17 | isoDate(date: any) : void;
18 | performRequest() : void;
19 | }
20 | }";
21 | AssertConfiguration(s =>
22 | {
23 | s.Global(a => a.DontWriteWarningComment().CamelCaseForMethods().CamelCaseForProperties().ReorderMembers());
24 | s.ExportAsInterface().WithPublicProperties().WithPublicMethods();
25 | }, result);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | enum EnumToIgnoreSomeValues
9 | {
10 | Value1,
11 | Value2,
12 | Value3
13 | }
14 |
15 | [Fact]
16 | public void EnumMultipleIgnoreValuesShouldPass()
17 | {
18 | const string result = @"
19 | module Reinforced.Typings.Tests.SpecificCases {
20 | export enum EnumToIgnoreSomeValues {
21 | Value3 = ""Value3""
22 | }
23 | }";
24 | AssertConfiguration(s =>
25 | {
26 | s.Global(a => a.DontWriteWarningComment());
27 | s.ExportAsEnum()
28 | .Value(EnumToIgnoreSomeValues.Value1, d => d.Ignore())
29 | .Value(EnumToIgnoreSomeValues.Value2, d => d.Ignore())
30 | .UseString();
31 | }, result);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsParameterAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 |
4 | namespace Reinforced.Typings.Attributes
5 | {
6 | ///
7 | /// Overrides settings for exporting parameters
8 | ///
9 | [AttributeUsage(AttributeTargets.Parameter)]
10 | public class TsParameterAttribute : TsTypedMemberAttributeBase, ISupportsInferring
11 | {
12 | private readonly InlineTypeInferers _typeInferers = new InlineTypeInferers();
13 |
14 | ///
15 | /// Specifies default value
16 | ///
17 | public virtual object DefaultValue { get; set; }
18 |
19 | ///
20 | /// Type inferers set instance
21 | ///
22 | public InlineTypeInferers TypeInferers
23 | {
24 | get { return _typeInferers; }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.ExportOrderTest1.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void ExportOrderTest1()
10 | {
11 | const string result1 = @"
12 | module Reinforced.Typings.Tests.SpecificCases {
13 | export interface ITestClass
14 | {
15 | String: string;
16 | Int: number;
17 | }
18 | export interface ITestInterface
19 | {
20 | String: string;
21 | Int: number;
22 | }
23 | }";
24 | AssertConfiguration(s =>
25 | {
26 | s.Global(a => a.DontWriteWarningComment());
27 | s.ExportAsInterface().WithPublicProperties();
28 | s.ExportAsInterface().WithPublicProperties().Order(-1);
29 | }, result1);
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/stuff/readme.txt:
--------------------------------------------------------------------------------
1 | Hello and welcome!
2 |
3 | You have just installed Reinforced.Typings NuGet package.
4 | It will help you to generate TypeScript definitions for your
5 | server-side C# code without pain.
6 |
7 | Reinforced.Typings can participate build process and
8 | generate TypeScript every time you Build/Rebuild your project.
9 | To activate this feature, your project must contain
10 | Reinforced.Typings.settings.xml file in the root.
11 |
12 | If Reinforced.Typings.settings.xml is already in place,
13 | you're all set! Readme can be closed, you may continue your work.
14 |
15 | If it is not, then you have to create one manually. Simply:
16 | 1) Go to you project root
17 | 2) Create file named Reinforced.Typings.settings.xml there
18 | 3) Copypaste default content into it
19 |
20 | That's it! Have fun and wish you happy development time.
21 |
22 | Oh, default content for Reinforced.Typings.settings.xml is following:
23 |
24 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Generators/ITsCodeGenerator.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 |
3 | namespace Reinforced.Typings.Generators
4 | {
5 | ///
6 | /// TypeScript code generator interface
7 | ///
8 | ///
9 | public interface ITsCodeGenerator
10 | {
11 | ///
12 | /// Export settings
13 | ///
14 | ExportContext Context { get; set; }
15 |
16 | ///
17 | /// Main code generator method. This method should return corresponding AST node for provided
18 | /// reflection element using source Reflection element and RT's Type Resolver
19 | ///
20 | /// Element code to be generated to output
21 | /// Type resolver
22 | RtNode Generate(TElement element, TypeResolver resolver);
23 | }
24 | }
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/ReinforcedTypings/Angular/AngularMethodAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Reinforced.Typings.Attributes;
3 |
4 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators.ReinforcedTypings.Angular
5 | {
6 | ///
7 | /// Attribute that we place above out controller's methods
8 | ///
9 | public class AngularMethodAttribute : TsFunctionAttribute
10 | {
11 | ///
12 | /// Constructor
13 | ///
14 | ///
15 | public AngularMethodAttribute(Type returnType)
16 | {
17 | // Here we override method return type for TypeScript export
18 | StrongType = returnType;
19 |
20 | // Here we are specifying code generator for particular method
21 | CodeGeneratorType = typeof (AngularActionCallGenerator);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.NvirthMultilineString.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | public class MyMultilineClass
9 | {
10 | public static string MyStaticProperty = @"My
11 | multiline
12 | string";
13 | }
14 |
15 |
16 | [Fact]
17 | public void NvirthMultilineString()
18 | {
19 | const string result = @"
20 | module Reinforced.Typings.Tests.SpecificCases {
21 | export class MyMultilineClass
22 | {
23 | public static MyStaticProperty: string = `My
24 | multiline
25 | string`;
26 | }
27 | }";
28 | AssertConfiguration(s =>
29 | {
30 | s.Global(a => a.DontWriteWarningComment());
31 | s.ExportAsClass().WithPublicFields().WithPublicProperties();
32 | }, result);
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsFileAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Attributes
4 | {
5 | ///
6 | /// Specifies file where to put generated code for type.
7 | /// This attribute is being ignored when RtDivideTypesAmongFiles is false.
8 | ///
9 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum)]
10 | public class TsFileAttribute : Attribute
11 | {
12 | ///
13 | /// Constructs new TsFile attribute
14 | ///
15 | /// File name (related to RtTargetDirectory) where to put generated code
16 | public TsFileAttribute(string fileName)
17 | {
18 | FileName = fileName;
19 | }
20 |
21 | ///
22 | /// File name (related to RtTargetDirectory) where to put generated code
23 | ///
24 | public string FileName { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/Typings/TypingsExportVisitor.RtConstructor.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | using Reinforced.Typings.Visitors.TypeScript;
3 | #pragma warning disable 1591
4 | namespace Reinforced.Typings.Visitors.Typings
5 | {
6 | partial class TypingsExportVisitor
7 | {
8 | public override void Visit(RtConstructor node)
9 | {
10 | if (node == null) return;
11 | Visit(node.Documentation);
12 | AppendTabs();
13 | if (Context == WriterContext.Interface)
14 | {
15 | Write("new (");
16 | }
17 | else
18 | {
19 | Write("constructor (");
20 | }
21 | SequentialVisit(node.Arguments, ", ");
22 | WriteLine(");");
23 |
24 | if (!string.IsNullOrEmpty(node.LineAfter))
25 | {
26 | AppendTabs();
27 | Write(node.LineAfter);
28 | Br();
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/Typings/TypingsExportVisitor.RtField.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | using Reinforced.Typings.Visitors.TypeScript;
3 | #pragma warning disable 1591
4 | namespace Reinforced.Typings.Visitors.Typings
5 | {
6 | partial class TypingsExportVisitor
7 | {
8 | public override void Visit(RtField node)
9 | {
10 | if (node == null) return;
11 | Visit(node.Documentation);
12 | AppendTabs();
13 |
14 | if (Context == WriterContext.Module) Write("export var ");
15 | if (Context == WriterContext.None) Write("declare var ");
16 | if (Context == WriterContext.Class) Modifiers(node);
17 |
18 | Visit(node.Identifier);
19 | Write(": ");
20 | Visit(node.Type);
21 | WriteLine(";");
22 | if (!string.IsNullOrEmpty(node.LineAfter))
23 | {
24 | AppendTabs();
25 | Write(node.LineAfter);
26 | Br();
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.FunctionalNames.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Reinforced.Typings.Fluent;
4 | using Xunit;
5 |
6 | namespace Reinforced.Typings.Tests.SpecificCases
7 | {
8 | public partial class SpecificTestCases
9 | {
10 | [Fact]
11 | public void FunctionalNames()
12 | {
13 | const string result = @"
14 | module Reinforced.Typings.Tests.SpecificCases {
15 | export interface ITestInterface
16 | {
17 | WoohooInt: number;
18 | WoohooString: string;
19 | }
20 | }";
21 | AssertConfiguration(s =>
22 | {
23 | s.Global(a => a.DontWriteWarningComment().ReorderMembers());
24 | s.ExportAsInterface()
25 | .WithPublicProperties(c => c.OverrideName("Woohoo" + c.Member.Name));
26 |
27 | s.ExportAsInterfaces(new List(), c => c.WithPublicProperties(x => x.OverrideName("_" + x.Member.Name)));
28 | }, result);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/IFilesOperations.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.ReferencesInspection;
2 |
3 | namespace Reinforced.Typings
4 | {
5 | ///
6 | /// Interface of files operator
7 | /// It has to be public for testing purposes
8 | ///
9 | public interface IFilesOperations
10 | {
11 | ///
12 | /// Export context
13 | ///
14 | ExportContext Context { set; }
15 |
16 | ///
17 | /// Writes temporary files contents to disk
18 | ///
19 | void DeployTempFiles();
20 |
21 | ///
22 | /// Cleans up temporary files registry
23 | ///
24 | void ClearTempRegistry();
25 |
26 | ///
27 | /// Exports specified syntax nodes to specified file
28 | ///
29 | /// File name
30 | /// File to be exported
31 | void Export(string fileName, ExportedFile file);
32 | }
33 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecifiicTestCases.UnresolvedToUnknown.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Xunit;
8 |
9 | namespace Reinforced.Typings.Tests.SpecificCases
10 | {
11 | public partial class SpecificTestCases
12 | {
13 | interface IUnresolvedToUnknownInterface
14 | {
15 | DateTime? Date { get; }
16 | }
17 |
18 | [Fact]
19 | public void UnresolvedToUnknown()
20 | {
21 | const string result = @"
22 | module Reinforced.Typings.Tests.SpecificCases {
23 | export interface IUnresolvedToUnknownInterface
24 | {
25 | Date: unknown;
26 | }
27 | }";
28 |
29 | AssertConfiguration(s =>
30 | {
31 | s.Global(c => c.UnresolvedToUnknown(true));
32 | s.ExportAsInterface().WithPublicProperties();
33 | }, result);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Mvc;
6 | using Reinforced.Typings.Samples.Simple.Quickstart.Models;
7 |
8 | namespace Reinforced.Typings.Samples.Simple.Quickstart.Controllers
9 | {
10 | public class HomeController : Controller
11 | {
12 | // GET: Home
13 |
14 | public ActionResult Index()
15 | {
16 | return View();
17 | }
18 |
19 | public ActionResult GetOrder(int orderId)
20 | {
21 | var orderVm = new OrderViewModel()
22 | {
23 | //Address = "88 Coleman Parkway",
24 | ClientName = "Katherine Perkins",
25 | IsPaid = false,
26 | ItemName = "Exametazime",
27 | Quantity = 38,
28 | Subtotal = 297.72
29 | };
30 |
31 | return Json(orderVm, JsonRequestBehavior.AllowGet);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/Dependency/RtReference.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Reinforced.Typings.Ast.Dependency
4 | {
5 | ///
6 | /// AST node for TS reference exposed as comment
7 | ///
8 | public class RtReference : RtNode
9 | {
10 | ///
11 | /// File to reference
12 | ///
13 | public string Path { get; set; }
14 |
15 | ///
16 | public override IEnumerable Children { get { yield break; } }
17 |
18 | ///
19 | public override void Accept(IRtVisitor visitor)
20 | {
21 | visitor.Visit(this);
22 | }
23 |
24 | ///
25 | public override void Accept(IRtVisitor visitor)
26 | {
27 | visitor.Visit(this);
28 | }
29 |
30 | ///
31 | public override string ToString()
32 | {
33 | return string.Format("///", Path);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.Fields.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | class TestExportWithFields
9 | {
10 | public string StringField;
11 | public int NumberField;
12 | }
13 |
14 | [Fact]
15 | public void FieldsWithBuilderConfig()
16 | {
17 | const string result = @"
18 | class TestExportWithFields
19 | {
20 | public StringField: string;
21 | public NumberField: number;
22 | }
23 | ";
24 |
25 | AssertConfiguration(s =>
26 | {
27 | s.Global(a => a.DontWriteWarningComment());
28 | s.ExportAsClass()
29 | .WithPublicFields((config) =>
30 | {
31 | var fieldInfo = config.Member;
32 | })
33 | .DontIncludeToNamespace()
34 | ;
35 | }, result);
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.PandaWoodForceNullableTest.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Attributes;
2 | using Reinforced.Typings.Fluent;
3 | using Xunit;
4 |
5 | namespace Reinforced.Typings.Tests.SpecificCases
6 | {
7 | public partial class SpecificTestCases
8 | {
9 | #region ForceNullable property
10 |
11 | public class PandaWoodForceNullableCase
12 | {
13 | [TsProperty(ForceNullable = true)]
14 | public string PandaWoodProperty { get; set; }
15 | }
16 |
17 | #endregion
18 |
19 | [Fact]
20 | public void PandaWoodForceNullableTest()
21 | {
22 | const string result = @"
23 | module Reinforced.Typings.Tests.SpecificCases {
24 | export class PandaWoodForceNullableCase
25 | {
26 | public PandaWoodProperty?: string;
27 | }
28 | }";
29 | AssertConfiguration(s =>
30 | {
31 | s.Global(a => a.DontWriteWarningComment());
32 | s.ExportAsClass();
33 | }, result);
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/Typings/TypingsExportVisitor.RtModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Reinforced.Typings.Ast;
3 | using Reinforced.Typings.Visitors.TypeScript;
4 | #pragma warning disable 1591
5 | namespace Reinforced.Typings.Visitors.Typings
6 | {
7 | partial class TypingsExportVisitor
8 | {
9 | public override void Visit(RtNamespace node)
10 | {
11 | if (node == null) return;
12 |
13 | if (!node.IsAmbientNamespace)
14 | {
15 | Context = WriterContext.Module;
16 | AppendTabs();
17 | WriteLine(String.Format("declare module {0} {{", node.Name));
18 | Tab();
19 | }
20 | foreach (var rtCompilationUnit in node.CompilationUnits)
21 | {
22 | Visit(rtCompilationUnit);
23 | }
24 | if (!node.IsAmbientNamespace)
25 | {
26 | Context = WriterContext.None;
27 | UnTab();
28 | AppendTabs();
29 | WriteLine("}");
30 | }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/RtMember.cs:
--------------------------------------------------------------------------------
1 | namespace Reinforced.Typings.Ast
2 | {
3 | ///
4 | /// Abstract AST node for class/interface member
5 | ///
6 | public abstract class RtMember : RtNode
7 | {
8 | ///
9 | /// JSDOC
10 | ///
11 | public RtJsdocNode Documentation { get; set; }
12 |
13 | ///
14 | /// Access modifier
15 | ///
16 | public AccessModifier? AccessModifier { get; set; }
17 |
18 | ///
19 | /// Is member static
20 | ///
21 | public bool IsStatic { get; set; }
22 |
23 | ///
24 | /// Gets or sets line that will follow after member
25 | ///
26 | public string LineAfter { get; set; }
27 |
28 | ///
29 | /// Member order
30 | ///
31 | public double Order
32 | {
33 | get { return _order; }
34 | set
35 | {
36 | _order = value;
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Exceptions/RtException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Exceptions
4 | {
5 | ///
6 | /// Base class for RT exception.
7 | /// All the RT exceptions will be provided to VisualStudio's errors tab
8 | ///
9 | public class RtException : Exception
10 | {
11 | ///
12 | /// Internal error code
13 | ///
14 | public int Code { get; private set; }
15 |
16 | ///
17 | /// Error subcategory
18 | ///
19 | public string Subcategory { get; private set; }
20 |
21 | ///
22 | /// Constructs new RT exception
23 | ///
24 | /// Error message
25 | /// Error code
26 | /// Error subcategory (optional)
27 | public RtException(string message, int code, string subcategory = "") : base(message)
28 | {
29 | Code = code;
30 | Subcategory = subcategory;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumKeyedDictionary.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void EnumKeyedDictionary()
10 | {
11 | const string result = @"
12 | export enum SomeEnum {
13 | One = 0,
14 | Two = 1
15 | }
16 | export interface IParametrizedGenericsInterface
17 | {
18 | Bag: { [key in SomeEnum]: string };
19 | Bag2: { [key:string]: SomeEnum }[];
20 | Bag3: { [key in SomeEnum]: SomeEnum }[][];
21 | Bag4: { [key in SomeEnum]: { [key:string]: SomeEnum[][] } };
22 | }";
23 | AssertConfiguration(s =>
24 | {
25 | s.Global(a => a.DontWriteWarningComment().UseModules());
26 | s.ExportAsEnum();
27 | s.ExportAsInterfaces(
28 | new[] {typeof(IParametrizedGenericsInterface)},
29 | x => x.WithPublicProperties().WithPublicMethods());
30 | }, result);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Fluent/TypeExtensions/TypeExportExtensions.Interface.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Reinforced.Typings.Generators;
3 | // ReSharper disable CheckNamespace
4 |
5 | namespace Reinforced.Typings.Fluent
6 | {
7 | public static partial class TypeExportExtensions
8 | {
9 | ///
10 | /// Specifies code generator for member
11 | ///
12 | public static InterfaceExportBuilder WithCodeGenerator(this InterfaceExportBuilder conf)
13 | where T : ITsCodeGenerator
14 | {
15 | conf.Attr.CodeGeneratorType = typeof(T);
16 | return conf;
17 | }
18 |
19 |
20 | ///
21 | /// Forces exporter to add I letter as interface prefix.
22 | ///
23 | /// Configuration
24 | /// Add I automatically or not
25 | public static T AutoI(this T conf, bool auto = true) where T: InterfaceExportBuilder
26 | {
27 | conf.Attr.AutoI = auto;
28 | return conf;
29 | }
30 |
31 | }
32 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtArgument.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | public override void Visit(RtArgument node)
8 | {
9 | if (node == null) return;
10 | Decorators(node);
11 | if (node.IsVariableParameters) Write("...");
12 | Visit(node.Identifier);
13 |
14 | // if a default value is used, then the parameter may be omitted as the default value is in place.
15 | if (Context == WriterContext.Interface && !node.Identifier.IsNullable && !string.IsNullOrEmpty(node.DefaultValue))
16 | {
17 | Write("?");
18 | }
19 |
20 | Write(": ");
21 | Visit(node.Type);
22 | if (Context != WriterContext.Interface && !string.IsNullOrEmpty(node.DefaultValue))
23 | {
24 | Write(" = ");
25 | Write(node.DefaultValue);
26 | }
27 | }
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/stuff/license.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Reinforced Opensource Products Family and Pavel B. Novikov personally
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.WeirdInheritanceCase.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void WeirdInheritanceCase()
10 | {
11 | const string result = @"
12 | export interface IBaseClass
13 | {
14 | Property: string;
15 | DoSomething() : void;
16 | }
17 | /**
18 | * @todo Automatically implemented from IBaseClass
19 | */
20 | export class DerivedClass implements IBaseClass
21 | {
22 | public Property: string;
23 | public DoSomething() : void { }
24 | public GetName() : string
25 | {
26 | return null;
27 | }
28 | }
29 | ";
30 | AssertConfiguration(s =>
31 | {
32 | s.Global(a => a.DontWriteWarningComment().UseModules().ReorderMembers());
33 | s.ExportAsInterface().WithPublicProperties().WithPublicMethods();
34 | s.ExportAsClass().WithPublicProperties().WithPublicMethods();
35 | }, result, compareComments: true);
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/ReinforcedTypings/jQuery/JQueryMethodAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Reinforced.Typings.Attributes;
3 |
4 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators.ReinforcedTypings.jQuery
5 | {
6 | ///
7 | /// Since controller method only can return ActionResult and
8 | /// there is no way to programmaticaly determine action result then
9 | /// we need special attribute to describe controller method return.
10 | /// We will inherit this attribute from TsFunction attribute since we
11 | /// anyway have to specify exported methods in fluent configuration either
12 | /// via attributes.
13 | ///
14 | public class JQueryMethodAttribute : TsFunctionAttribute
15 | {
16 | public JQueryMethodAttribute(Type returnType)
17 | {
18 | // Here we override method return type for TypeScript export
19 | StrongType = returnType;
20 |
21 | // Here we are specifying code generator for particular method
22 | CodeGeneratorType = typeof (JQueryActionCallGenerator);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Reinforced.Typings.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Reinforced.Typings.Samples.Difficult.CodeGenerators.ReinforcedTypings.Configuration.Configure
12 |
13 |
14 |
15 | true
16 |
17 |
18 | $(ProjectDir)Scripts\ReinforcedTypings\Generated
19 |
20 |
21 | false
22 |
23 |
24 | false
25 |
26 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtField.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | public override void Visit(RtField node)
8 | {
9 | if (node == null) return;
10 | Visit(node.Documentation);
11 | AppendTabs();
12 | if (Context != WriterContext.Interface)
13 | {
14 | Decorators(node);
15 | Modifiers(node);
16 | }
17 | Visit(node.Identifier);
18 | Write(": ");
19 | Visit(node.Type);
20 | if (!string.IsNullOrEmpty(node.InitializationExpression))
21 | {
22 | Write(" = ");
23 | Write(node.InitializationExpression);
24 | }
25 | Write(";");
26 | Br();
27 | if (!string.IsNullOrEmpty(node.LineAfter))
28 | {
29 | AppendTabs();
30 | Write(node.LineAfter);
31 | Br();
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.ExportOrderTest2.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public partial class SpecificTestCases
7 | {
8 | [Fact]
9 | public void ExportOrderTest2()
10 | {
11 | const string result2 = @"
12 | module Reinforced.Typings.Tests.SpecificCases {
13 | export interface ITestInterface
14 | {
15 | Int: number;
16 | String: string;
17 | }
18 | export interface ITestClass
19 | {
20 | String: string;
21 | Int: number;
22 | }
23 | export class TestClass2
24 | {
25 | public Int: number;
26 | public String: string;
27 | }
28 | }";
29 | AssertConfiguration(s =>
30 | {
31 | s.Global(a => a.DontWriteWarningComment());
32 | s.ExportAsInterface().WithPublicProperties().WithProperty(c=>c.String).Order(1);
33 | s.ExportAsInterface().WithPublicProperties();
34 | s.ExportAsClass().WithPublicProperties().WithProperty(c => c.Int).Order(-1);
35 | }, result2);
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsReferenceAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Reinforced.Typings.Ast.Dependency;
3 |
4 | namespace Reinforced.Typings.Attributes
5 | {
6 | ///
7 | /// Specifies path of reference which required to be added to result .ts file
8 | ///
9 | [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
10 | public class TsReferenceAttribute : Attribute
11 | {
12 | ///
13 | /// Constructs new instance of TsReferenceAttribute
14 | ///
15 | /// Path that should be written as file to reference tag
16 | public TsReferenceAttribute(string path)
17 | {
18 | Path = path;
19 | }
20 |
21 | ///
22 | /// Path to referenced TS file
23 | ///
24 | public virtual string Path { get; private set; }
25 |
26 | private RtReference _reference;
27 |
28 | internal RtReference ToReference()
29 | {
30 | if (_reference==null) _reference = new RtReference() {Path = Path};
31 | return _reference;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Generators/FieldCodeGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 |
4 | namespace Reinforced.Typings.Generators
5 | {
6 | ///
7 | /// Default code generator for fields
8 | ///
9 | public class FieldCodeGenerator : PropertyCodeGenerator
10 | {
11 | ///
12 | /// That's it - overriden GetType for property since properties and fields are exported to TypeScript almost same way.
13 | ///
14 | /// Member info (Fields behind)
15 | /// Field type
16 | protected override Type GetType(MemberInfo mi)
17 | {
18 | var pi = (FieldInfo) mi;
19 | return pi.FieldType;
20 | }
21 |
22 | ///
23 | /// Retrieves static value
24 | ///
25 | ///
26 | ///
27 | protected override object GetStaticValue(MemberInfo element)
28 | {
29 | var fi = element as FieldInfo;
30 | return fi.GetValue(null) ?? fi.GetRawConstantValue();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/Typings/TypingsExportVisitor.RtFunction.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | using Reinforced.Typings.Visitors.TypeScript;
3 | #pragma warning disable 1591
4 | namespace Reinforced.Typings.Visitors.Typings
5 | {
6 | partial class TypingsExportVisitor
7 | {
8 | public override void Visit(RtFunction node)
9 | {
10 | if (node == null) return;
11 | Visit(node.Documentation);
12 | AppendTabs();
13 | if (Context != WriterContext.Interface) Modifiers(node);
14 | if (Context == WriterContext.Module) Write("export function ");
15 | Visit(node.Identifier);
16 | Write("(");
17 | SequentialVisit(node.Arguments, ", ");
18 | Write(") ");
19 | if (node.ReturnType != null)
20 | {
21 | Write(": ");
22 | Visit(node.ReturnType);
23 | }
24 | WriteLine(";");
25 | if (!string.IsNullOrEmpty(node.LineAfter))
26 | {
27 | AppendTabs();
28 | Write(node.LineAfter);
29 | Br();
30 | }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Fluent/MemberExtensions/MemberExportExtensions.Parameter.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using Reinforced.Typings.Ast;
3 | using Reinforced.Typings.Generators;
4 | // ReSharper disable CheckNamespace
5 |
6 | namespace Reinforced.Typings.Fluent
7 | {
8 | public static partial class MemberExportExtensions
9 | {
10 | ///
11 | /// Sets parameter default value.
12 | ///
13 | /// Configuration
14 | /// Default value for parameter
15 | public static ParameterExportBuilder DefaultValue(this ParameterExportBuilder conf, object value)
16 | {
17 | conf.Attr.DefaultValue = value;
18 | return conf;
19 | }
20 |
21 | ///
22 | /// Specifies code generator for member
23 | ///
24 | public static ParameterExportBuilder WithCodeGenerator(this ParameterExportBuilder conf)
25 | where T : TsCodeGeneratorBase
26 | {
27 | conf.Attr.CodeGeneratorType = typeof(T);
28 | return conf;
29 | }
30 |
31 | }
32 | }
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2019 Reinforced Opensource Products Family and Pavel B. Novikov personally
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Reinforced.Typings.Dev.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net5.0
4 | Reinforced.Typings
5 | false
6 | false
7 | false
8 | None
9 | AnyCPU;x64;x86
10 |
11 | Reinforced.Typings
12 | Reinforced Software Construction OSS
13 | Pavel B. Novikov 2019
14 | $(AssemblyName)
15 | 1.5.9
16 | 1.5.9
17 | 1.5.9
18 | $(DefineConstants);NETCORE;
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Scripts/app/HomeIndex.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | module Reinforced.Typings.Samples.Simple.Quickstart {
4 | import OrderViewModel = Reinforced.Typings.Samples.Simple.Quickstart.Models.IOrderViewModel;
5 |
6 | export class HomeIndexPage{
7 | constructor() {
8 | $(document).ready(this.documentReady.bind(this));
9 | }
10 |
11 | private documentReady() {
12 | $('#btnRequest').click(this.onRequest.bind(this));
13 | $('#btnSend').click(this.onSend.bind(this));
14 | }
15 |
16 | private onRequest() {
17 | $.ajax({
18 | url: '/Home/GetOrder?orderId=10',
19 | success:this.handleResponse
20 | });
21 | }
22 |
23 | private handleResponse(data: OrderViewModel) {
24 | var text = `${data.ClientName}, ${data.Address} (${data.ItemName}, ${data.Quantity})`;
25 | $('#divInfo').text(text);
26 | }
27 |
28 | private onSend() {
29 |
30 | }
31 | }
32 | }
33 |
34 | window['homeIndexPage'] = new Reinforced.Typings.Samples.Simple.Quickstart.HomeIndexPage();
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.Dependencies.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast.Dependency;
2 | using Reinforced.Typings.Ast.TypeNames;
3 |
4 | #pragma warning disable 1591
5 |
6 | namespace Reinforced.Typings.Visitors.TypeScript
7 | {
8 | partial class TypeScriptExportVisitor
9 | {
10 | public override void Visit(RtImport node)
11 | {
12 | Write("import ");
13 | if (node.Target != null)
14 | {
15 | Write(node.Target);
16 | Write(" ");
17 | if (node.IsRequire)
18 | {
19 | WriteLine(string.Format("= require('{0}');", node.From));
20 | }
21 | else
22 | {
23 | WriteLine(string.Format("from '{0}';", node.From));
24 | }
25 | }
26 | else
27 | {
28 | WriteLine(string.Format("'{0}';", node.From));
29 | }
30 |
31 | }
32 |
33 | public override void Visit(RtReference node)
34 | {
35 | WriteLine(string.Format("///", node.Path));
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtInterface.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Reinforced.Typings.Ast;
3 | #pragma warning disable 1591
4 | namespace Reinforced.Typings.Visitors.TypeScript
5 | {
6 | partial class TypeScriptExportVisitor
7 | {
8 | public override void Visit(RtInterface node)
9 | {
10 | if (node == null) return;
11 | Visit(node.Documentation);
12 | var prev = Context;
13 | Context = WriterContext.Interface;
14 | AppendTabs();
15 | if (node.Export) Write("export ");
16 | Write("interface ");
17 | Visit(node.Name);
18 | if (node.Implementees.Count > 0)
19 | {
20 | Write(" extends ");
21 | SequentialVisit(node.Implementees, ", ");
22 | }
23 | Br(); AppendTabs();
24 | Write("{"); Br();
25 | Tab();
26 | foreach (var rtMember in DoSortMembers(node.Members))
27 | {
28 | Visit(rtMember);
29 | }
30 | UnTab();
31 | AppendTabs(); WriteLine("}");
32 | Context = prev;
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/TsDecoratorAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Attributes
4 | {
5 | ///
6 | /// Adds decorator to class/method/parameter/property
7 | ///
8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Field, AllowMultiple = true)]
9 | public class TsDecoratorAttribute : Attribute
10 | {
11 | ///
12 | /// Decorator text - everything that must follow after @
13 | ///
14 | public string Decorator { get; set; }
15 |
16 | ///
17 | /// Decorator order
18 | ///
19 | public double Order { get; set; }
20 |
21 | ///
22 | /// Creates decorator attribute
23 | ///
24 | /// Decorator text - everything that follows after @
25 | /// Decorator order of appearence
26 | public TsDecoratorAttribute(string decorator,double order = 0)
27 | {
28 | Decorator = decorator;
29 | Order = order;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.ExportEnums.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Fluent;
2 | using Xunit;
3 |
4 | namespace Reinforced.Typings.Tests.SpecificCases
5 | {
6 | public enum TestEnum1
7 | {
8 | A, B, C
9 | }
10 |
11 | public enum TestEnum2
12 | {
13 | ///
14 | /// C Value
15 | ///
16 | C,
17 |
18 | ///
19 | /// D Value
20 | ///
21 | D,
22 | ///
23 | /// E Value
24 | ///
25 | E
26 | }
27 | public partial class SpecificTestCases
28 | {
29 | [Fact]
30 | public void ExportEnums()
31 | {
32 | const string result = @"
33 | module Reinforced.Typings.Tests.SpecificCases {
34 | export enum TestEnum1 {
35 | A = 0,
36 | B = 1,
37 | C = 2
38 | }
39 | export enum TestEnum2 {
40 | C = 0,
41 | D = 1,
42 | E = 2
43 | }
44 | }";
45 | AssertConfiguration(s =>
46 | {
47 | s.Global(a => a.DontWriteWarningComment());
48 | s.ExportAsEnums(new[] { typeof(TestEnum1), typeof(TestEnum2) });
49 | }, result);
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtJsdocNode.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | public override void Visit(RtJsdocNode node)
8 | {
9 | if (node == null) return;
10 |
11 | if (!string.IsNullOrEmpty(node.Description) && !node.Description.Contains("\n") && node.TagToDescription.Count == 0)
12 | {
13 | //handle single-line JSDOC
14 | AppendTabs(); Write("/** "); Write(node.Description); WriteLine(" */");
15 | }
16 | else
17 | {
18 | AppendTabs(); WriteLine("/**");
19 | if (!string.IsNullOrEmpty(node.Description))
20 | {
21 | Summary(node.Description);
22 | if (node.TagToDescription.Count > 0) DocLine();
23 | }
24 | foreach (var tuple in node.TagToDescription)
25 | {
26 | DocTag(tuple.Item1, tuple.Item2);
27 | }
28 | AppendTabs(); WriteLine("*/");
29 | }
30 | }
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializers.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Attributes;
2 | using Reinforced.Typings.Fluent;
3 | using Xunit;
4 |
5 | namespace Reinforced.Typings.Tests.SpecificCases
6 | {
7 | public partial class SpecificTestCases
8 | {
9 | enum SomeInitializerEnum
10 | {
11 | Value1,
12 | Value2,
13 | [TsValue(Initializer = "Three")]
14 | Value3
15 | }
16 | [Fact]
17 | public void EnumStringInitializers()
18 | {
19 | const string result = @"
20 | module Reinforced.Typings.Tests.SpecificCases {
21 | export enum SomeInitializerEnum {
22 | Value1 = ""One"",
23 |
24 | Value2 = ""Two"",
25 | Value3 = ""Three""
26 |
27 | }
28 | }";
29 | AssertConfiguration(s =>
30 | {
31 | s.Global(a => a.DontWriteWarningComment());
32 | s.ExportAsEnum()
33 | .Value(SomeInitializerEnum.Value1, d => d.Initializer("One"))
34 | .Value(SomeInitializerEnum.Value2, d => d.Initializer("Two"))
35 | .UseString();
36 | }, result);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.HierarchyFlattening4.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Reflection;
4 | using Reinforced.Typings.Fluent;
5 | using Xunit;
6 |
7 | namespace Reinforced.Typings.Tests.SpecificCases
8 | {
9 |
10 | public partial class SpecificTestCases
11 | {
12 | [Fact]
13 | public void HierarchyFlattening4()
14 | {
15 | const string result = @"
16 | module Reinforced.Typings.Tests.SpecificCases {
17 | export interface IFlattenChild1
18 | {
19 | Name_For_1: number;
20 | }
21 | export interface IFlattenChild2
22 | {
23 | Name_For_2: number;
24 | }
25 | }
26 | ";
27 | AssertConfiguration(s =>
28 | {
29 | s.Global(a => a.DontWriteWarningComment().ReorderMembers());
30 |
31 | s.ExportAsInterface()
32 | .FlattenHierarchy()
33 | .WithProperty(x => x.Name, x => x.OverrideName("Name_For_1"));
34 |
35 | s.ExportAsInterface()
36 | .FlattenHierarchy()
37 | .WithProperty(x => x.Name, x => x.OverrideName("Name_For_2"));
38 |
39 |
40 | }, result);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.GenericGuidDictionary.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Reinforced.Typings.Ast.TypeNames;
5 | using Reinforced.Typings.Fluent;
6 | using Xunit;
7 |
8 | namespace Reinforced.Typings.Tests.SpecificCases
9 | {
10 | public partial class SpecificTestCases
11 | {
12 | class A
13 | {
14 | public IDictionary GuidDictionary { get; set; }
15 | }
16 |
17 | [Fact]
18 | public void GenericGuidDictionary()
19 | {
20 | const string result = @"
21 | module Reinforced.Typings.Tests.SpecificCases {
22 | export interface IA
23 | {
24 | GuidDictionary: { [key:string]: string };
25 | }
26 | }";
27 | AssertConfiguration(s =>
28 | {
29 | s.Global(a => a.DontWriteWarningComment().ReorderMembers());
30 | s.Substitute(typeof(Guid), new RtSimpleTypeName("string"));
31 | s.ExportAsInterface().WithPublicProperties();
32 |
33 | }, result, exp =>
34 | {
35 | var warnings = exp.Context.Warnings.Count();
36 | Assert.Equal(0, warnings);
37 | });
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Attributes/IAutoexportSwitchAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Reinforced.Typings.Attributes
4 | {
5 | ///
6 | /// Interface containing base properties for some attributes
7 | ///
8 | public interface IAutoexportSwitchAttribute
9 | {
10 | ///
11 | /// When true, code for all methods will be automatically generated
12 | ///
13 | bool AutoExportMethods { get; set; }
14 |
15 | ///
16 | /// When true, code for all properties will be automatically generated
17 | ///
18 | bool AutoExportProperties { get; set; }
19 |
20 | ///
21 | /// When true, code for all fields will be automatically generated
22 | ///
23 | bool AutoExportFields { get; }
24 |
25 | ///
26 | /// Reference to code geenrator which will be applied to every method
27 | ///
28 | Type DefaultMethodCodeGenerator { get; }
29 |
30 | ///
31 | /// When true, code for all constructors will be automatically generated
32 | ///
33 | bool AutoExportConstructors { get; }
34 |
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Fluent/MemberBuilders/MemberExportBuilder.Method.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using Reinforced.Typings.Attributes;
3 | // ReSharper disable CheckNamespace
4 |
5 | namespace Reinforced.Typings.Fluent
6 | {
7 | ///
8 | /// Fluent export configuration builder for method
9 | ///
10 | public class MethodExportBuilder : MemberExportBuilder, ISupportsInferring
11 | {
12 | /// Initializes a new instance of the class.
13 | internal MethodExportBuilder(TypeBlueprint containingTypeBlueprint, MemberInfo member) : base(containingTypeBlueprint, member)
14 | {
15 | }
16 |
17 | internal TsFunctionAttribute Attr
18 | {
19 | get { return (TsFunctionAttribute)_forMember; }
20 | }
21 |
22 | ///
23 | /// Gets method being configured
24 | ///
25 | public MethodInfo Member
26 | {
27 | get { return (MethodInfo)_member; }
28 | }
29 |
30 | ///
31 | /// Type inferers set instance
32 | ///
33 | public InlineTypeInferers TypeInferers
34 | {
35 | get { return Attr.TypeInferers; }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Fluent/MemberBuilders/MemberExportBuilder.Property.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using Reinforced.Typings.Attributes;
3 | // ReSharper disable CheckNamespace
4 |
5 | namespace Reinforced.Typings.Fluent
6 | {
7 | ///
8 | /// Fluent export configuration builder for property or field
9 | ///
10 | public class PropertyExportBuilder : MemberExportBuilder, ISupportsInferring
11 | {
12 | /// Initializes a new instance of the class.
13 | internal PropertyExportBuilder(TypeBlueprint containingTypeBlueprint, MemberInfo member) : base(containingTypeBlueprint, member)
14 | {
15 | }
16 |
17 | internal TsPropertyAttribute Attr
18 | {
19 | get { return (TsPropertyAttribute)_forMember; }
20 | }
21 |
22 | ///
23 | /// Gets property being configured
24 | ///
25 | public PropertyInfo Member
26 | {
27 | get { return (PropertyInfo) _member; }
28 | }
29 |
30 | ///
31 | /// Type inferers set instance
32 | ///
33 | public InlineTypeInferers TypeInferers
34 | {
35 | get { return Attr.TypeInferers; }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/ITypeMember.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Reinforced.Typings.Ast.TypeNames;
3 |
4 | namespace Reinforced.Typings.Ast
5 | {
6 | ///
7 | /// Abstraction for RtClass and RtInterface AST
8 | ///
9 | public interface ITypeMember
10 | {
11 | ///
12 | /// Denotes current class to be exported
13 | ///
14 | bool Export { get; set; }
15 |
16 | ///
17 | /// Denotes that current class must be default export of module
18 | ///
19 | bool DefaultExport { get; set; }
20 |
21 | ///
22 | /// JSDOC
23 | ///
24 | RtJsdocNode Documentation { get; set; }
25 |
26 | ///
27 | /// Class/interface members
28 | ///
29 | List Members { get; }
30 |
31 | ///
32 | /// class/interface name
33 | ///
34 | RtSimpleTypeName Name { get; set; }
35 |
36 | ///
37 | /// Implementing types names
38 | ///
39 | List Implementees { get; }
40 |
41 | ///
42 | /// Order of writing
43 | ///
44 | double Order { get; set; }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Ast/RtEnumValue.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Reinforced.Typings.Ast
4 | {
5 | ///
6 | /// AST node for TypeScript enumeration value
7 | ///
8 | public class RtEnumValue : RtNode
9 | {
10 | ///
11 | /// JSDOC
12 | ///
13 | public RtJsdocNode Documentation { get; set; }
14 |
15 | ///
16 | /// Value name
17 | ///
18 | public string EnumValueName { get; set; }
19 |
20 | ///
21 | /// Value value
22 | ///
23 | public string EnumValue { get; set; }
24 |
25 | ///
26 | /// Gets or sets line that will follow after member
27 | ///
28 | public string LineAfter { get; set; }
29 |
30 | ///
31 | public override IEnumerable Children
32 | {
33 | get { yield break; }
34 | }
35 |
36 | ///
37 | public override void Accept(IRtVisitor visitor)
38 | {
39 | visitor.Visit(this);
40 | }
41 |
42 | ///
43 | public override void Accept(IRtVisitor visitor)
44 | {
45 | visitor.Visit(this);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtEnum.cs:
--------------------------------------------------------------------------------
1 | using Reinforced.Typings.Ast;
2 | #pragma warning disable 1591
3 | namespace Reinforced.Typings.Visitors.TypeScript
4 | {
5 | partial class TypeScriptExportVisitor
6 | {
7 | public override void Visit(RtEnum node)
8 | {
9 | if (node == null) return;
10 | Visit(node.Documentation);
11 | var prev = Context;
12 | Context = WriterContext.Enum;
13 | AppendTabs();
14 | if (node.Export) Write("export ");
15 | if (node.IsConst) Write("const ");
16 | Write("enum ");
17 | Visit(node.EnumName);
18 | WriteLine(" {");
19 | Tab();
20 | var arr = node.Values.ToArray();
21 | for (int i = 0; i < arr.Length; i++)
22 | {
23 | Visit(arr[i]);
24 | if (i != arr.Length - 1) WriteLine(",");
25 | if (!string.IsNullOrEmpty(arr[i].LineAfter))
26 | {
27 | AppendTabs();
28 | Write(arr[i].LineAfter);
29 | Br();
30 | }
31 | }
32 | WriteLine(string.Empty);
33 | UnTab();
34 | AppendTabs();
35 | WriteLine("}");
36 | Context = prev;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/ReferencesInspection/ImportComparer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Reinforced.Typings.Ast.Dependency;
3 |
4 | namespace Reinforced.Typings.ReferencesInspection
5 | {
6 | sealed class ImportComparer : IEqualityComparer
7 | {
8 | public bool Equals(RtImport x, RtImport y)
9 | {
10 | if (ReferenceEquals(x, y)) return true;
11 | if (ReferenceEquals(x, null)) return false;
12 | if (ReferenceEquals(y, null)) return false;
13 | if (x.GetType() != y.GetType()) return false;
14 | return string.Equals(x.Target, y.Target) && string.Equals(x.From, y.From) && x.IsRequire == y.IsRequire;
15 | }
16 |
17 | public int GetHashCode(RtImport obj)
18 | {
19 | unchecked
20 | {
21 | var hashCode = (obj.Target != null ? obj.Target.GetHashCode() : 0);
22 | hashCode = (hashCode * 397) ^ (obj.From != null ? obj.From.GetHashCode() : 0);
23 | hashCode = (hashCode * 397) ^ obj.IsRequire.GetHashCode();
24 | return hashCode;
25 | }
26 | }
27 |
28 | private static readonly ImportComparer _instance = new ImportComparer();
29 |
30 | public static ImportComparer Instance
31 | {
32 | get { return _instance; }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Reinforced.Typings/Generators/InterfaceCodeGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Reinforced.Typings.Ast;
3 | using Reinforced.Typings.Attributes;
4 |
5 | namespace Reinforced.Typings.Generators
6 | {
7 | ///
8 | /// Default code generator for interfaces. Derived from class generator since interfaces are very similar to classes in
9 | /// TypeScript
10 | ///
11 | public class InterfaceCodeGenerator : ClassAndInterfaceGeneratorBase
12 | {
13 | ///
14 | /// Main code generator method. This method should write corresponding TypeScript code for element (1st argument) to
15 | /// WriterWrapper (3rd argument) using TypeResolver if necessary
16 | ///
17 | /// Element code to be generated to output
18 | /// Resulting node
19 | /// Type resolver
20 | public override RtInterface GenerateNode(Type element,RtInterface result, TypeResolver resolver)
21 | {
22 | var tc = Context.Project.Blueprint(element).Attr();
23 | if (tc == null) throw new ArgumentException("TsInterfaceAttribute is not present", "element");
24 | Export(result, element, resolver, tc);
25 | return result;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.InlineFunctionImplementation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Reinforced.Typings.Fluent;
3 | using Xunit;
4 |
5 | namespace Reinforced.Typings.Tests.SpecificCases
6 | {
7 | public partial class SpecificTestCases
8 | {
9 | [Fact]
10 | public void InlineFunctionImplementation()
11 | {
12 | string implementation1 = Guid.NewGuid().ToString() + ";";
13 | string implementation2 = Guid.NewGuid().ToString() + ";";
14 |
15 | string result = $@"
16 | module Reinforced.Typings.Tests.SpecificCases {{
17 | export class ClassWithManyMethods
18 | {{
19 | public DoSomethingElse() : void
20 | {{
21 | {implementation1}
22 | }}
23 | public DoSomethingElseWithResult() : string
24 | {{
25 | {implementation2}
26 | }}
27 | public DoSomethinig() : void
28 | {{
29 | {implementation1}
30 | }}
31 | }}
32 | }}";
33 | AssertConfiguration(s =>
34 | {
35 | s.Global(a => a.DontWriteWarningComment().ReorderMembers());
36 | s.ExportAsClass()
37 | .WithPublicMethods(c => c.Implement(implementation1))
38 | .WithMethod(c => c.DoSomethingElseWithResult(), c => c.Implement(implementation2))
39 | ;
40 | }, result);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/Reinforced.Typings/Fluent/Parameter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq.Expressions;
3 | using System.Reflection;
4 |
5 | namespace Reinforced.Typings.Fluent
6 | {
7 | ///
8 | /// Shortcut for method parameters mocking
9 | ///
10 | public class Ts
11 | {
12 |
13 | internal static MethodInfo ParametrizedParameterMethod;
14 |
15 | static Ts()
16 | {
17 | Expression> lambda = () => Parameter