├── 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(a => a.Ignore()); 18 | ParametrizedParameterMethod = LambdaHelpers.ParseMethodLambda(lambda).GetGenericMethodDefinition(); 19 | } 20 | 21 | /// 22 | /// Parameter mock for specified type 23 | /// 24 | /// Parameter type 25 | /// Mock 26 | public static T Parameter() 27 | { 28 | return default(T); 29 | } 30 | 31 | /// 32 | /// Parameter mock with parameter configuration 33 | /// 34 | /// Parameter type 35 | /// Fluent parameter configuration 36 | /// Mock 37 | public static T Parameter(Action configuration) 38 | { 39 | return default(T); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Reinforced.Typings/Ast/RtDecorator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Reinforced.Typings.Ast 4 | { 5 | /// 6 | /// Syntax node for TS decorator 7 | /// 8 | public class RtDecorator : RtNode 9 | { 10 | /// 11 | /// Decorator name (everything that must follow after "@") 12 | /// 13 | public string Decorator { get; private set; } 14 | 15 | /// 16 | /// Order of appearence 17 | /// 18 | public double Order { get; set; } 19 | 20 | /// 21 | public override IEnumerable Children { get {yield break;} } 22 | 23 | /// 24 | public override void Accept(IRtVisitor visitor) 25 | { 26 | visitor.Visit(this); 27 | } 28 | 29 | /// 30 | public override void Accept(IRtVisitor visitor) 31 | { 32 | visitor.Visit(this); 33 | } 34 | 35 | /// 36 | /// Constructs new RtDecorator 37 | /// 38 | /// Decorator content 39 | /// Decorator order 40 | public RtDecorator(string decorator, double order = 0) 41 | { 42 | Decorator = decorator; 43 | Order = order; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Reinforced.Typings/Attributes/TsFunctionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Reinforced.Typings.Attributes 5 | { 6 | /// 7 | /// Overrides function export 8 | /// 9 | [AttributeUsage(AttributeTargets.Method)] 10 | public class TsFunctionAttribute : TsTypedMemberAttributeBase, ISupportsInferring 11 | { 12 | private readonly InlineTypeInferers _typeInferers = new InlineTypeInferers(); 13 | 14 | /// 15 | /// Sets order this membter will be written to output file in 16 | /// 17 | public double Order { get; set; } 18 | 19 | /// 20 | /// Inline function code to be converted to RtRaw and used as function body 21 | /// 22 | public string Implementation { get; set; } 23 | 24 | /// 25 | /// Gets or sets whether function forcibly should be made async/left as usual function 26 | /// 27 | public bool? ForceAsync { get; set; } 28 | 29 | /// 30 | /// Type inferers set instance 31 | /// 32 | public InlineTypeInferers TypeInferers 33 | { 34 | get { return _typeInferers; } 35 | // ReSharper disable once ValueParameterNotUsed 36 | private set { } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Content/prismjs/cshtml.js: -------------------------------------------------------------------------------- 1 | Prism.languages.cshtml = Prism.languages.extend('markup', { 2 | 'razor_comment': { 3 | pattern: /@\*[\w\W]*?\*@/, 4 | greedy:false, 5 | inside: { 6 | razor_comment_begin: /@\*/, 7 | razor_comment_end: /\*@/ 8 | } 9 | }, 10 | 'razor_block': { 11 | pattern: /@\{[\w\W]*?\}(?=[\s\S]*(@|\<))/, 12 | greedy:true, 13 | inside :{ 14 | 'razor_borders': /@\{/, 15 | 'razor_end': { 16 | pattern: /\}$/ , 17 | alias:'razor_borders' 18 | } 19 | } 20 | }, 21 | 22 | 'razor_keyword': /@(model|using|section|if|foreach)/, 23 | 'razor_inline': { 24 | greedy:false, 25 | pattern: /@[\w]([\w\.]|\([\w\"\~\\\/\s\,\:\(\$\.\)]*\))+/, 26 | inside: { 27 | 'razor_borders': /^@/, 28 | } 29 | } 30 | }); 31 | Prism.languages.cshtml['razor_block'].inside.rest = Prism.util.clone(Prism.languages.csharp); 32 | Prism.languages.cshtml['razor_inline'].inside.rest = Prism.util.clone(Prism.languages.csharp); 33 | Prism.languages.cshtml['razor_inline'].inside['razor_pageclass'] = /\b(Html|Url|Ajax|this|Model|ViewBag|Styles|Scripts)\b/; 34 | Prism.languages.cshtml['razor_block'].inside['razor_pageclass'] = /\b(Html|Url|Ajax|this|Model|ViewBag|Styles|Scripts)\b/; -------------------------------------------------------------------------------- /Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Scripts/app/HomeIndex.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"HomeIndex.js","sourceRoot":"","sources":["HomeIndex.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAEpD,IAAO,UAAU,CA6BhB;AA7BD,WAAO,UAAU;IAAC,IAAA,OAAO,CA6BxB;IA7BiB,WAAA,OAAO;QAAC,IAAA,OAAO,CA6BhC;QA7ByB,WAAA,OAAO;YAAC,IAAA,MAAM,CA6BvC;YA7BiC,WAAA,MAAM;gBAAC,IAAA,UAAU,CA6BlD;gBA7BwC,WAAA,UAAU;oBAG/C;wBACI;4BACI,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBACrD,CAAC;wBAEO,qCAAa,GAArB;4BACI,CAAC,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;4BAClD,CAAC,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBAChD,CAAC;wBAEO,iCAAS,GAAjB;4BACI,CAAC,CAAC,IAAI,CAAC;gCACH,GAAG,EAAE,2BAA2B;gCAChC,OAAO,EAAC,IAAI,CAAC,cAAc;6BAC9B,CAAC,CAAC;wBACP,CAAC;wBAEO,sCAAc,GAAtB,UAAuB,IAAoB;4BACvC,IAAI,IAAI,GAAM,IAAI,CAAC,UAAU,UAAK,IAAI,CAAC,OAAO,UAAK,IAAI,CAAC,QAAQ,UAAK,IAAI,CAAC,QAAQ,MAAG,CAAC;4BACtF,CAAC,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAC7B,CAAC;wBAEO,8BAAM,GAAd;wBAEA,CAAC;wBACL,oBAAC;oBAAD,CAAC,AAzBD,IAyBC;oBAzBY,wBAAa,gBAyBzB,CAAA;gBACL,CAAC,EA7BwC,UAAU,GAAV,iBAAU,KAAV,iBAAU,QA6BlD;YAAD,CAAC,EA7BiC,MAAM,GAAN,cAAM,KAAN,cAAM,QA6BvC;QAAD,CAAC,EA7ByB,OAAO,GAAP,eAAO,KAAP,eAAO,QA6BhC;IAAD,CAAC,EA7BiB,OAAO,GAAP,kBAAO,KAAP,kBAAO,QA6BxB;AAAD,CAAC,EA7BM,UAAU,KAAV,UAAU,QA6BhB;AAED,MAAM,CAAC,eAAe,CAAC,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC"} -------------------------------------------------------------------------------- /Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.AutoOptional.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 | interface OptionalTestInterface 10 | { 11 | DateTime? Date { get; } 12 | int? Number { get; } 13 | string String { get; } 14 | } 15 | 16 | class OptionalTestClass 17 | { 18 | public DateTime? Date { get; } 19 | public int? Number { get; } 20 | public string String { get; } 21 | } 22 | [Fact] 23 | public void AutoOptional() 24 | { 25 | const string result = @" 26 | module Reinforced.Typings.Tests.SpecificCases { 27 | export interface IOptionalTestInterface 28 | { 29 | Date?: any; 30 | Number?: number; 31 | String: string; 32 | } 33 | export interface IOptionalTestClass 34 | { 35 | Date?: any; 36 | Number?: number; 37 | String: string; 38 | } 39 | }"; 40 | AssertConfiguration(s => 41 | { 42 | s.Global(a => a.DontWriteWarningComment().AutoOptionalProperties()); 43 | s.ExportAsInterface().WithPublicProperties(); 44 | s.ExportAsInterface().WithPublicProperties(); 45 | }, result); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Reinforced.Typings/Attributes/TsGenericAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | // ReSharper disable VirtualMemberCallInConstructor 3 | 4 | namespace Reinforced.Typings.Attributes 5 | { 6 | /// 7 | /// Denotes type for generic attribute 8 | /// 9 | [AttributeUsage(AttributeTargets.GenericParameter)] 10 | public class TsGenericAttribute : TsTypedAttributeBase, ISupportsInferring 11 | { 12 | private readonly InlineTypeInferers _typeInferers = new InlineTypeInferers(); 13 | 14 | /// 15 | /// Constructs new instance of TsGenericAttribute 16 | /// 17 | /// Raw TypeScript type name 18 | public TsGenericAttribute(string type) 19 | { 20 | Type = type; 21 | } 22 | 23 | /// 24 | /// Constructs new instance of TsGenericAttribute 25 | /// 26 | /// Type to be resolved to TypeScript name during export 27 | public TsGenericAttribute(Type strongType) 28 | { 29 | StrongType = strongType; 30 | } 31 | 32 | /// 33 | /// Type inferers set instance 34 | /// 35 | public InlineTypeInferers TypeInferers 36 | { 37 | get { return _typeInferers; } 38 | private set { } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Optimization; 2 | 3 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators 4 | { 5 | public class BundleConfig 6 | { 7 | 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( 15 | "~/Scripts/jquery.validate*")); 16 | 17 | // Use the development version of Modernizr to develop with and learn from. Then, when you're 18 | // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 19 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 20 | "~/Scripts/modernizr-*")); 21 | 22 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 23 | "~/Scripts/bootstrap.js", 24 | "~/Scripts/respond.js")); 25 | 26 | bundles.Add(new StyleBundle("~/Content/css").Include( 27 | "~/Content/bootstrap.css", 28 | "~/Content/site.css")); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtConstructor.cs: -------------------------------------------------------------------------------- 1 | using System; 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(RtConstructor node) 9 | { 10 | if (node == null) return; 11 | if (Context == WriterContext.Interface) return; 12 | Visit(node.Documentation); 13 | AppendTabs(); 14 | Write("constructor ("); 15 | SequentialVisit(node.Arguments, ", "); 16 | Write(")"); 17 | if (node.NeedsSuperCall && node.Body == null) 18 | { 19 | string ncp = string.Empty; 20 | if (node.SuperCallParameters != null) ncp = string.Join(", ", node.SuperCallParameters); 21 | node.Body = new RtRaw(String.Format("super({0});", ncp)); 22 | } 23 | 24 | if (node.Body != null && !string.IsNullOrEmpty(node.Body.RawContent)) 25 | { 26 | CodeBlock(node.Body); 27 | } 28 | else 29 | { 30 | EmptyBody(null); 31 | } 32 | 33 | if (!string.IsNullOrEmpty(node.LineAfter)) 34 | { 35 | AppendTabs(); 36 | Write(node.LineAfter); 37 | Br(); 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Reinforced.Typings/ExportContext/ExportContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace Reinforced.Typings 6 | { 7 | /// 8 | /// TsExport exporting settings 9 | /// 10 | public sealed partial class ExportContext : IWarningsCollector 11 | { 12 | 13 | private bool _isLocked; 14 | 15 | /// 16 | /// Instantiates new ExportContext instance (only for testing/integration) 17 | /// 18 | public ExportContext(Assembly[] sourceAssemblies, IFilesOperations fileOperationsServiceOverride = null) 19 | { 20 | FileOperations = fileOperationsServiceOverride ?? new FilesOperations(); 21 | FileOperations.Context = this; 22 | Global = new GlobalParameters(sourceAssemblies); 23 | SourceAssemblies = sourceAssemblies; 24 | Location = new Location(this); 25 | Project = new ProjectBlueprint(); 26 | } 27 | 28 | /// 29 | /// There is a case when you are exporting base class as interface. It may lead to some unusual handling of generation, 30 | /// so I'm using this property to denote such cases and fix it in-place 31 | /// 32 | internal bool SpecialCase { get; set; } 33 | 34 | internal Dictionary> TypesToFilesMap { get; private set; } 35 | } 36 | } -------------------------------------------------------------------------------- /Reinforced.Typings/Reinforced.Typings.NETCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net10.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.6.7 16 | 1.6.7 17 | 1.6.7 18 | $(DefineConstants);$(RtAdditionalConstants); 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.DecoratorsTest.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 Decorators 10 | 11 | public class ClassWithMethods 12 | { 13 | public string String { get; set; } 14 | public int Int { get; set; } 15 | 16 | [TsDecorator("b()")] 17 | public void DoSomethinig() 18 | { 19 | 20 | } 21 | } 22 | 23 | 24 | 25 | #endregion 26 | 27 | [Fact] 28 | public void DecoratorsTest() 29 | { 30 | const string result = @" 31 | module Reinforced.Typings.Tests.SpecificCases { 32 | @sealed export class ClassWithMethods 33 | { 34 | @bind public Int: number; 35 | @bind public String: string; 36 | @a() @b() public DoSomethinig() : void { } 37 | } 38 | }"; 39 | AssertConfiguration(s => 40 | { 41 | s.Global(a => a.DontWriteWarningComment().ReorderMembers()); 42 | s.ExportAsClass() 43 | .WithPublicProperties(a => a.Decorator("bind")) 44 | .WithMethod(c => c.DoSomethinig(), c => c.Decorator("a()", -1)) 45 | .Decorator("sealed") 46 | ; 47 | }, result); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Reinforced.Typings/Exceptions/RtWarning.cs: -------------------------------------------------------------------------------- 1 | namespace Reinforced.Typings.Exceptions 2 | { 3 | /// 4 | /// Represents warning message that could be displayed during build. 5 | /// Warnings can be added to global warnings collection located at ExportContext.Warnings. 6 | /// ExportContext instance can be found inside every TsCodeGeneratorBase 7 | /// 8 | public class RtWarning 9 | { 10 | /// 11 | /// Warning code 12 | /// 13 | public int Code { get; set; } 14 | 15 | /// 16 | /// Warning subcategory 17 | /// 18 | public string Subcategory { get; set; } 19 | 20 | /// 21 | /// Warning detailed text 22 | /// 23 | public string Text { get; set; } 24 | 25 | /// 26 | /// Instantiates new RtWarning that is suitable be added to warnings collection. 27 | /// 28 | /// Warning code 29 | /// Warning subcategory (optional). Important! Warning subcategory should not contain word "warning" and ":" symbol 30 | /// Warning text 31 | public RtWarning(int code, string subcategory = null, string text = null) 32 | { 33 | Code = code; 34 | Subcategory = subcategory; 35 | Text = text; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtNamespace.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Reinforced.Typings.Ast; 4 | #pragma warning disable 1591 5 | namespace Reinforced.Typings.Visitors.TypeScript 6 | { 7 | partial class TypeScriptExportVisitor 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 | if (node.GenerationMode == NamespaceGenerationMode.Module) 18 | { 19 | WriteLine(String.Format("module {0} {{", node.Name)); 20 | } 21 | else 22 | { 23 | if (node.Export) Write("export "); 24 | WriteLine(String.Format("namespace {0} {{", node.Name)); 25 | } 26 | Tab(); 27 | } 28 | foreach (var rtCompilationUnit in node.CompilationUnits.OrderBy(c => c is RtCompilationUnit ? ((RtCompilationUnit) c).Order : 0)) 29 | { 30 | Visit(rtCompilationUnit); 31 | } 32 | if (!node.IsAmbientNamespace) 33 | { 34 | Context = WriterContext.None; 35 | UnTab(); 36 | AppendTabs(); 37 | WriteLine("}"); 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.OverrideNamespaceWithModules.cs: -------------------------------------------------------------------------------- 1 | using Reinforced.Typings.Fluent; 2 | using Xunit; 3 | 4 | namespace TypingsExample.Long.Namespace.Structure 5 | { 6 | class MyClass 7 | { 8 | public MyProperty Property { get; set; } 9 | } 10 | 11 | class MyProperty 12 | { 13 | public string Name { get; set; } 14 | } 15 | } 16 | namespace Reinforced.Typings.Tests.SpecificCases 17 | { 18 | public partial class SpecificTestCases 19 | { 20 | [Fact] 21 | public void OverrideNamespaceWithModules() 22 | { 23 | const string result = @" 24 | export namespace server { 25 | export class MyClass 26 | { 27 | public Property: server.MyProperty; 28 | } 29 | export class MyProperty 30 | { 31 | public Name: string; 32 | } 33 | }"; 34 | var types = new[] 35 | { 36 | typeof(TypingsExample.Long.Namespace.Structure.MyClass), 37 | typeof(TypingsExample.Long.Namespace.Structure.MyProperty) 38 | }; 39 | AssertConfiguration(s => 40 | { 41 | s.Global(a => a.DontWriteWarningComment().UseModules(true, false)); 42 | s.ExportAsClasses( 43 | types, 44 | conf => conf 45 | .OverrideNamespace("server") 46 | .WithAllProperties() 47 | ); 48 | }, result); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Reinforced.Typings.Cli/Reinforced.Typings.Cli.Dev.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net5.0 4 | Exe 5 | Reinforced.Typings.Cli 6 | false 7 | false 8 | None 9 | Reinforced.Typings.Cli.Bootstrapper 10 | true 11 | true 12 | AnyCPU;x64;x86 13 | 14 | rtcli 15 | Reinforced Software Construction OSS 16 | Pavel B. Novikov 2019 17 | $(AssemblyName) 18 | 1.5.9 19 | 1.5.9 20 | 1.5.9 21 | $(DefineConstants);NETCORE; 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtClass.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(RtClass node) 9 | { 10 | if (node == null) return; 11 | Visit(node.Documentation); 12 | var prev = Context; 13 | Context = WriterContext.Class; 14 | AppendTabs(); 15 | Decorators(node); 16 | if (node.Export) Write("export "); 17 | if (node.Abstract) Write("abstract "); 18 | Write("class "); 19 | Visit(node.Name); 20 | if (node.Extendee != null) 21 | { 22 | Write(" extends "); 23 | Visit(node.Extendee); 24 | } 25 | if (node.Implementees.Count > 0) 26 | { 27 | Write(" implements "); 28 | SequentialVisit(node.Implementees, ", "); 29 | } 30 | Br(); AppendTabs(); 31 | Write("{"); Br(); 32 | Tab(); 33 | var members = DoSortMembers(node.Members); 34 | foreach (var rtMember in members) 35 | { 36 | Visit(rtMember); 37 | } 38 | UnTab(); 39 | AppendTabs(); WriteLine("}"); 40 | Context = prev; 41 | } 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/ReinforcedTypings/query.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"query.js","sourceRoot":"","sources":["query.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;IAAA;IA4CA,CAAC;IA3CG;;;;;;OAMG;IACW,qBAAK,GAAnB,UAAuB,GAAW,EAAE,IAAS,EAAE,gBAAwB,EAAE,eAA2B;QAA3B,gCAAA,EAAA,oBAA2B;QAChG,IAAI,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,IAAI,KAAK,GAAG;YACR,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAC1B,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,MAAM;YAChB,WAAW,EAAC,kBAAkB;YAC9B,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE;gBACN,EAAE,CAAC,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;oBAClD,CAAC,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC1E,CAAC;gBACD,EAAE,CAAC,CAAC,eAAe,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;oBAChD,CAAC,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;gBAC/C,CAAC;YACL,CAAC;YACD,OAAO,EAAE,UAAC,QAAW;gBACjB,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;YACD,KAAK,EAAE,UAAC,OAAO,EAAE,MAAM,EAAE,KAAK;gBAC1B,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAC/E,CAAC;SACJ,CAAC;QAEF,EAAE,CAAC,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YAClD,CAAC,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,sGAAsG,CAAC,CAAC;QACvI,CAAC;QAED,EAAE,CAAC,CAAC,eAAe,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YAChD,CAAC,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,UAAU,EAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;QAED,CAAC,CAAC,IAAI,CAAC,GAAG,EAAM,KAAK,CAAC,CAAC;QACvB,MAAM,CAAC,OAAO,CAAC;IACnB,CAAC;IACL,sBAAC;AAAD,CAAC,AA5CD,IA4CC"} -------------------------------------------------------------------------------- /Reinforced.Typings/ReferencesInspection/ReferenceProcessorBase.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Reinforced.Typings.Ast.Dependency; 3 | 4 | namespace Reinforced.Typings.ReferencesInspection 5 | { 6 | /// 7 | /// Base class for reference post-processor. 8 | /// 9 | public abstract class ReferenceProcessorBase 10 | { 11 | /// 12 | /// Returns refiltered and reordered import directives that must appear in resulting file. 13 | /// Return null to remain references list untouched 14 | /// 15 | /// Set on initially computed imports 16 | /// File that is being exported currently 17 | /// Set of refiltered/reordered imports 18 | public abstract IEnumerable FilterImports(IEnumerable imports, ExportedFile file); 19 | 20 | /// 21 | /// Returns refiltered and reordered reference directives that must appear in resulting file 22 | /// Return null to remain imports list untouched 23 | /// 24 | /// Set on initially computed references 25 | /// File that is being exported currently 26 | /// Set of refiltered/reordered references 27 | public abstract IEnumerable FilterReferences(IEnumerable references, ExportedFile file); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.NewForceNullable.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 New ForceNullable test 10 | 11 | public interface INewForceNullableTest 12 | { 13 | [TsProperty(ForceNullable = true)] 14 | int? NilInt { get; } 15 | int NotNilInt { get; } 16 | int? ForceNotNullableInt { get; } 17 | int ForceNullableInt { get; } 18 | } 19 | 20 | #endregion 21 | 22 | [Fact] 23 | public void NewForceNullable() 24 | { 25 | const string result = @" 26 | module Reinforced.Typings.Tests.SpecificCases { 27 | export interface INewForceNullableTest 28 | { 29 | ForceNotNullableInt: number; 30 | ForceNullableInt?: number; 31 | NilInt?: number; 32 | NotNilInt: number; 33 | } 34 | }"; 35 | AssertConfiguration(s => 36 | { 37 | s.Global(a => a.DontWriteWarningComment().ReorderMembers()); 38 | s.ExportAsInterface() 39 | .WithPublicProperties() 40 | .WithProperty(c => c.ForceNotNullableInt, c => c.ForceNullable(false)) 41 | .WithProperty(c => c.ForceNullableInt, c => c.ForceNullable()) 42 | ; 43 | }, result); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/angular-cookies.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | AngularJS v1.4.8 3 | (c) 2010-2015 Google, Inc. http://angularjs.org 4 | License: MIT 5 | */ 6 | (function(p,c,n){'use strict';function l(b,a,g){var d=g.baseHref(),k=b[0];return function(b,e,f){var g,h;f=f||{};h=f.expires;g=c.isDefined(f.path)?f.path:d;c.isUndefined(e)&&(h="Thu, 01 Jan 1970 00:00:00 GMT",e="");c.isString(h)&&(h=new Date(h));e=encodeURIComponent(b)+"="+encodeURIComponent(e);e=e+(g?";path="+g:"")+(f.domain?";domain="+f.domain:"");e+=h?";expires="+h.toUTCString():"";e+=f.secure?";secure":"";f=e.length+1;4096 4096 bytes)!");k.cookie=e}}c.module("ngCookies",["ng"]).provider("$cookies",[function(){var b=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(a,g){return{get:function(d){return a()[d]},getObject:function(d){return(d=this.get(d))?c.fromJson(d):d},getAll:function(){return a()},put:function(d,a,m){g(d,a,m?c.extend({},b,m):b)},putObject:function(d,b,a){this.put(d,c.toJson(b),a)},remove:function(a,k){g(a,n,k?c.extend({},b,k):b)}}}]}]);c.module("ngCookies").factory("$cookieStore", 8 | ["$cookies",function(b){return{get:function(a){return b.getObject(a)},put:function(a,c){b.putObject(a,c)},remove:function(a){b.remove(a)}}}]);l.$inject=["$document","$log","$browser"];c.module("ngCookies").provider("$$cookieWriter",function(){this.$get=l})})(window,window.angular); 9 | //# sourceMappingURL=angular-cookies.min.js.map 10 | -------------------------------------------------------------------------------- /Reinforced.Typings/Visitors/Typings/TypingsExportVisitor.RtEnum.cs: -------------------------------------------------------------------------------- 1 | using Reinforced.Typings.Ast; 2 | using Reinforced.Typings.Visitors.TypeScript; 3 | 4 | #pragma warning disable 1591 5 | namespace Reinforced.Typings.Visitors.Typings 6 | { 7 | partial class TypingsExportVisitor 8 | { 9 | public override void Visit(RtEnum node) 10 | { 11 | if (node == null) return; 12 | Visit(node.Documentation); 13 | var prev = Context; 14 | Context = WriterContext.Enum; 15 | AppendTabs(); 16 | if (node.Export) 17 | { 18 | if (prev == WriterContext.Module) Write("export "); 19 | else Write("declare "); 20 | } 21 | if (node.IsConst) Write("const "); 22 | Write("enum "); 23 | Visit(node.EnumName); 24 | WriteLine(" {"); 25 | Tab(); 26 | var arr = node.Values.ToArray(); 27 | for (int i = 0; i < arr.Length; i++) 28 | { 29 | Visit(arr[i]); 30 | if (i != arr.Length - 1) WriteLine(","); 31 | if (!string.IsNullOrEmpty(arr[i].LineAfter)) 32 | { 33 | AppendTabs(); 34 | Write(arr[i].LineAfter); 35 | Br(); 36 | } 37 | } 38 | WriteLine(string.Empty); 39 | UnTab(); 40 | AppendTabs(); 41 | WriteLine("}"); 42 | Context = prev; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /TestFluentAssembly/TestFluentAssembly.NETCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Debug 4 | AnyCPU 5 | {E7E010D2-1CE5-4877-ABA7-36EA8EC62118} 6 | Library 7 | Properties 8 | TestFluentAssembly 9 | TestFluentAssembly 10 | netstandard2.0;netstandard2.1;netcoreapp2.1;netcoreapp3.1;netcoreapp2.2 11 | 512 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug\ 18 | DEBUG;TRACE 19 | prompt 20 | 4 21 | 22 | 23 | pdbonly 24 | true 25 | bin\Release\ 26 | TRACE 27 | prompt 28 | 4 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.DaggmanoAutoIBug.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 DaggmanoAutoIBug() 10 | { 11 | const string result = @" 12 | module Reinforced.Typings.Tests.SpecificCases { 13 | export interface IInternalUserDaggmano 14 | { 15 | Name: string; 16 | } 17 | export interface IExternalUserDaggmano 18 | { 19 | Name: string; 20 | } 21 | export interface IAlreadyContainsI 22 | { 23 | Name: string; 24 | } 25 | export interface IDoesntContainI 26 | { 27 | Name: string; 28 | } 29 | export class DoNotNeedIAtAll 30 | { 31 | public Name: string; 32 | } 33 | export class ICannotBeRemovedHere 34 | { 35 | public Name: string; 36 | } 37 | }"; 38 | AssertConfiguration(s => 39 | { 40 | s.Global(a => a.DontWriteWarningComment().ReorderMembers()); 41 | s.ExportAsInterface().WithPublicProperties(); 42 | s.ExportAsInterface().WithPublicProperties(); 43 | s.ExportAsInterface().WithPublicProperties(); 44 | s.ExportAsInterface().WithPublicProperties(); 45 | s.ExportAsClass().WithPublicProperties(); 46 | s.ExportAsClass().WithPublicProperties(); 47 | }, result); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /TestFluentAssembly/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestFluentAssembly")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestFluentAssembly")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e7e010d2-1ce5-4877-aba7-36ea8ec62118")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.DocumentationForNestedTypes.cs: -------------------------------------------------------------------------------- 1 | using Reinforced.Typings.Fluent; 2 | using Xunit; 3 | 4 | namespace Reinforced.Typings.Tests.SpecificCases 5 | { 6 | public partial class SpecificTestCases 7 | { 8 | /// 9 | /// Some documentation for nested class 10 | /// 11 | public class SomeReallyNestedClass 12 | { 13 | /// Ctor comment 14 | public SomeReallyNestedClass(int x) 15 | { 16 | } 17 | } 18 | [Fact] 19 | public void DocumentationForNestedTypes() 20 | { 21 | const string result = @" 22 | module Reinforced.Typings.Tests.SpecificCases { 23 | /** Some documentation for nested class */ 24 | export class SomeReallyNestedClass 25 | { 26 | /** Ctor comment */ 27 | constructor (x: number) { } 28 | } 29 | } 30 | "; 31 | AssertConfiguration(s => 32 | { 33 | s.Global(a => a.DontWriteWarningComment().GenerateDocumentation()); 34 | s.TryLookupDocumentationForAssembly(typeof(SpecificTestCases).Assembly); 35 | s.ExportAsClass() 36 | .WithPublicProperties() 37 | .WithConstructor(); 38 | }, result, exp => 39 | { 40 | var doc = exp.Context.Documentation.GetDocumentationMember(typeof(SomeReallyNestedClass)); 41 | Assert.NotNull(doc); 42 | }, compareComments: true); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Reinforced.Typings.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Reinforced.Typings.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5d126898-7e5d-4967-8732-3fc8722f532e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Reinforced.Typings.Samples.Difficult.CodeGenerators")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Reinforced.Typings.Samples.Difficult.CodeGenerators")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("3ea8aeee-b88c-406e-8686-72127ee1bf7c")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | [assembly: AssemblyVersion("1.0.0.0")] 34 | [assembly: AssemblyFileVersion("1.0.0.0")] 35 | -------------------------------------------------------------------------------- /Reinforced.Typings.Cli/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Reinforced.WebTypings.Console")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Reinforced.WebTypings.Console")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b1103c7e-f5a2-4ac5-a5bc-7107b4d0fd69")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Reinforced.Typings/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | 9 | [assembly: AssemblyTitle("DynamicMvcTypings")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("DynamicMvcTypings")] 14 | [assembly: AssemblyCopyright("Copyright © 2015")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: CLSCompliant(true)] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | 23 | [assembly: ComVisible(false)] 24 | 25 | // The following GUID is for the ID of the typelib if this project is exposed to COM 26 | 27 | [assembly: Guid("f05e4940-fa83-446c-97ff-b0d7fb56daee")] 28 | 29 | // Version information for an assembly consists of the following four values: 30 | // 31 | // Major Version 32 | // Minor Version 33 | // Build Number 34 | // Revision 35 | // 36 | // You can specify all the values or you can default the Build and Revision Numbers 37 | // by using the '*' as shown below: 38 | // [assembly: AssemblyVersion("1.0.*")] 39 | 40 | [assembly: AssemblyVersion("1.0.0.0")] 41 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /Reinforced.Typings/Visitors/Typings/TypingsExportVisitor.RtClass.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 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(RtClass node) 10 | { 11 | if (node == null) return; 12 | Visit(node.Documentation); 13 | var prev = Context; 14 | Context = WriterContext.Class; 15 | AppendTabs(); 16 | if (prev == WriterContext.Module) Write("export "); 17 | else Write("declare "); 18 | if (node.Abstract) Write("abstract "); 19 | Write("class "); 20 | Visit(node.Name); 21 | if (node.Extendee != null) 22 | { 23 | Write(" extends "); 24 | Visit(node.Extendee); 25 | } 26 | if (node.Implementees.Count > 0) 27 | { 28 | Write(" implements "); 29 | SequentialVisit(node.Implementees, ", "); 30 | } 31 | Br(); 32 | AppendTabs(); 33 | Write("{"); 34 | Br(); 35 | Tab(); 36 | var members = DoSortMembers(node.Members); 37 | foreach (var rtMember in members) 38 | { 39 | Visit(rtMember); 40 | } 41 | UnTab(); 42 | AppendTabs(); 43 | WriteLine("}"); 44 | Context = prev; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Reinforced.Typings.Integrate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Reinforced.Typings.Integrate")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Reinforced.Typings.Integrate")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0e333cad-85ca-4636-88e8-f72a8ad9b8c5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.NewLineTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Reinforced.Typings.Ast; 3 | using Reinforced.Typings.Fluent; 4 | using Reinforced.Typings.Generators; 5 | using Xunit; 6 | 7 | namespace Reinforced.Typings.Tests.SpecificCases 8 | { 9 | public partial class SpecificTestCases 10 | { 11 | [Fact] 12 | public void NewLineTest_Default() { 13 | var newLine = Environment.NewLine; 14 | string result = $"module Reinforced.Typings.Tests.SpecificCases {{{newLine}export interface ITestInterface{newLine}{{{newLine}Int: number;{newLine}String: string;{newLine}}}{newLine}}}{newLine}"; 15 | AssertConfiguration(s => { 16 | s.Global(a => a.DontWriteWarningComment().TabSymbol(string.Empty).ReorderMembers()); 17 | s.ExportAsInterface().WithPublicProperties(); 18 | }, result); 19 | } 20 | 21 | [Fact] 22 | public void NewLineTest_Explicit() { 23 | const string newLine = "\n"; 24 | string result = $"module Reinforced.Typings.Tests.SpecificCases {{{newLine}export interface ITestInterface{newLine}{{{newLine}Int: number;{newLine}String: string;{newLine}}}{newLine}}}{newLine}"; 25 | var actual = AssertConfiguration(s => { 26 | s.Global(a => a.DontWriteWarningComment().TabSymbol(string.Empty).NewLine(newLine).ReorderMembers()); 27 | s.ExportAsInterface().WithPublicProperties(); 28 | }, result); 29 | 30 | Assert.Equal(result, actual); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Reinforced.Typings/Ast/RtJsdocNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Reinforced.Typings.Ast 5 | { 6 | /// 7 | /// AST node for JSDOC documentation 8 | /// 9 | public class RtJsdocNode : RtNode 10 | { 11 | /// 12 | /// Main documentation text 13 | /// 14 | public string Description { get; set; } 15 | 16 | /// 17 | /// Additional JSDOC documentation tags 18 | /// 19 | public List> TagToDescription { get; private set; } 20 | 21 | /// 22 | /// Constructs new instance of AST node 23 | /// 24 | public RtJsdocNode() 25 | { 26 | TagToDescription = new List>(); 27 | } 28 | 29 | /// 30 | public override IEnumerable Children 31 | { 32 | get { yield break; } 33 | } 34 | 35 | /// 36 | public override void Accept(IRtVisitor visitor) 37 | { 38 | visitor.Visit(this); 39 | } 40 | 41 | /// 42 | public override void Accept(IRtVisitor visitor) 43 | { 44 | visitor.Visit(this); 45 | } 46 | 47 | /// 48 | /// Adds an additional JSDOC documentation tag. 49 | /// 50 | public void AddTag(DocTag tag, string value = null) => 51 | TagToDescription.Add(new Tuple(tag, value)); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Reinforced.Typings.Samples.Simple.Quickstart")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Reinforced.Typings.Samples.Simple.Quickstart")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2d8f2d97-c5a6-4ed7-a672-2bdda660eaed")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.OverridenNamesNotCamelCased.cs: -------------------------------------------------------------------------------- 1 | using Reinforced.Typings.Attributes; 2 | using Reinforced.Typings.Fluent; 3 | using Xunit; 4 | 5 | namespace Reinforced.Typings.Tests.SpecificCases 6 | { 7 | public class TestOverrides 8 | { 9 | [TsProperty(Name = "ID", ForceNullable = true)] 10 | public virtual int _id { get { return 0; } } 11 | 12 | [TsFunction(Name = "DO_DOMETHING")] 13 | public void DoSomething() { } 14 | 15 | public void AnotherMethod() { } 16 | 17 | public string AnotherProeprty { get; set; } 18 | } 19 | public partial class SpecificTestCases 20 | { 21 | 22 | 23 | [Fact] 24 | public void OverridenNamesNotCamelCased() 25 | { 26 | const string result = @" 27 | module Reinforced.Typings.Tests.SpecificCases { 28 | export interface ITestOverrides 29 | { 30 | Another_Property: string; 31 | ID?: number; 32 | Another_Method() : void; 33 | DO_DOMETHING() : void; 34 | } 35 | }"; 36 | AssertConfiguration(s => 37 | { 38 | s.Global(a => a.DontWriteWarningComment().CamelCaseForMethods().CamelCaseForProperties().ReorderMembers()); 39 | s.ExportAsInterface() 40 | .WithPublicProperties() 41 | .WithPublicMethods() 42 | .WithMethod(x => x.AnotherMethod(), x => x.OverrideName("Another_Method")) 43 | .WithProperty(x => x.AnotherProeprty, x => x.OverrideName("Another_Property")) 44 | ; 45 | }, result); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/ReinforcedTypings/Configuration.cs: -------------------------------------------------------------------------------- 1 | using Reinforced.Typings.Attributes; 2 | using Reinforced.Typings.Fluent; 3 | using Reinforced.Typings.Samples.Difficult.CodeGenerators.Controllers; 4 | using Reinforced.Typings.Samples.Difficult.CodeGenerators.Models; 5 | using Reinforced.Typings.Samples.Difficult.CodeGenerators.ReinforcedTypings.Angular; 6 | 7 | [assembly: TsGlobal(GenerateDocumentation = true)] 8 | 9 | namespace Reinforced.Typings.Samples.Difficult.CodeGenerators.ReinforcedTypings 10 | { 11 | public class Configuration 12 | { 13 | public static void Configure(ConfigurationBuilder builder) 14 | { 15 | 16 | // --- For both tutorials 17 | // Configuration exporting test model class as interface 18 | builder.ExportAsInterface().WithPublicProperties().ExportTo("models.ts"); 19 | 20 | // --- For jQuery Tutorial 21 | // Configuration for JQueryController 22 | // Setting code generator for each method performed in JQueryMethodAttribute 23 | builder.ExportAsClass().ExportTo("JQueryController.ts"); 24 | 25 | // --- For Angular tutorial 26 | // Configuration for Angular.js-firndly controller 27 | // Setting code generator for methods also performed in attribute - see AngularMethodAttribute 28 | builder.ExportAsClass() 29 | .ExportTo("AngularController.ts") 30 | .WithCodeGenerator(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.NestedClassInheritance.cs: -------------------------------------------------------------------------------- 1 | using Reinforced.Typings.Fluent; 2 | using Xunit; 3 | 4 | namespace TestA 5 | { 6 | public class TestParentClassA 7 | { 8 | public string Id { get; set; } 9 | public string Name { get; set; } 10 | } 11 | 12 | } 13 | 14 | namespace TestB 15 | { 16 | using TestA; 17 | public class SomeOtherClass 18 | { 19 | public class SomeDerivedClass : TestParentClassA 20 | { 21 | public int OtherId { get; set; } 22 | } 23 | } 24 | } 25 | 26 | namespace Reinforced.Typings.Tests.SpecificCases 27 | { 28 | 29 | public partial class SpecificTestCases 30 | { 31 | [Fact] 32 | public void NestedClassInheritance() 33 | { 34 | const string result = @" 35 | module TestB { 36 | export interface ISomeDerivedClass extends TestB.ITestParentClassA 37 | { 38 | OtherId: number; 39 | } 40 | export interface ITestParentClassA 41 | { 42 | id: string; 43 | text: string; 44 | } 45 | }"; 46 | AssertConfiguration(s => 47 | { 48 | s.Global(a => a.DontWriteWarningComment().ReorderMembers()); 49 | s.ExportAsInterface() 50 | .WithPublicProperties(); 51 | s.ExportAsInterface() 52 | .WithProperty(c => c.Id, v => v.OverrideName("id")) 53 | .WithProperty(c => c.Name, v => v.OverrideName("text")) 54 | .OverrideNamespace("TestB"); 55 | }, result); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Reinforced.Typings/Ast/RtRaw.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Reinforced.Typings.Ast 4 | { 5 | /// 6 | /// AST node exposing raw text to be output to resulting file 7 | /// 8 | public class RtRaw : RtNode 9 | { 10 | 11 | /// 12 | /// Constructs new instance of AST node 13 | /// 14 | public RtRaw() 15 | { 16 | } 17 | 18 | /// 19 | /// Constructs new instance of AST node 20 | /// 21 | /// Raw text to be output to resulting file 22 | public RtRaw(string rawContent) 23 | { 24 | RawContent = rawContent; 25 | } 26 | 27 | /// 28 | /// Raw text to be output to resulting file 29 | /// 30 | public string RawContent { get; set; } 31 | 32 | /// 33 | /// Order of RtRaw appearance 34 | /// 35 | public double Order 36 | { 37 | get { return _order; } 38 | set { _order = value; } 39 | } 40 | 41 | /// 42 | public override IEnumerable Children 43 | { 44 | get { yield break; } 45 | } 46 | 47 | /// 48 | public override void Accept(IRtVisitor visitor) 49 | { 50 | visitor.Visit(this); 51 | } 52 | 53 | /// 54 | public override void Accept(IRtVisitor visitor) 55 | { 56 | visitor.Visit(this); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Reinforced.Typings/Fluent/MemberExtensions/MemberExportExtensions.EnumValue.cs: -------------------------------------------------------------------------------- 1 | using Reinforced.Typings.Attributes; 2 | // ReSharper disable CheckNamespace 3 | 4 | namespace Reinforced.Typings.Fluent 5 | { 6 | public static partial class MemberExportExtensions 7 | { 8 | /// 9 | /// Adds decorator to member 10 | /// 11 | /// Member configurator 12 | /// Decorator to add (everything that must follow after "@") 13 | /// Order of appearence 14 | /// Fluent 15 | public static EnumValueExportBuilder Decorator(this EnumValueExportBuilder conf, string decorator, double order = 0) 16 | { 17 | conf.Decorators.Add(new TsDecoratorAttribute(decorator, order)); 18 | return conf; 19 | } 20 | 21 | /// 22 | /// Overrides name of exported type 23 | /// 24 | /// Configuration 25 | /// Custom name to be used 26 | public static EnumValueExportBuilder OverrideName(this EnumValueExportBuilder conf, string name) 27 | { 28 | conf.Attr.Name = name; 29 | return conf; 30 | } 31 | 32 | /// 33 | /// Ignores specified mambers during exporting 34 | /// 35 | public static EnumValueExportBuilder Ignore(this EnumValueExportBuilder conf, bool ignore = true) 36 | { 37 | conf.Ignore = ignore; 38 | return conf; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Reinforced.Typings/Generators/ClassCodeGenerator.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 CLR type (class) 9 | /// 10 | public class ClassCodeGenerator : ClassAndInterfaceGeneratorBase 11 | { 12 | /// 13 | /// Main code generator method. This method should write corresponding TypeScript code for element (1st argument) to 14 | /// WriterWrapper (3rd argument) using TypeResolver if necessary 15 | /// 16 | /// Element code to be generated to output 17 | /// Resulting node 18 | /// Type resolver 19 | public override RtClass GenerateNode(Type element, RtClass result, TypeResolver resolver) 20 | { 21 | 22 | var clsbp = Context.Project.Blueprint(element); 23 | var tc = Context.Project.Blueprint(element).Attr(); 24 | if (tc == null) throw new ArgumentException("TsClassAttribute is not present", "element"); 25 | Export(result, element, resolver, tc); 26 | AddDecorators(result, clsbp.GetDecorators()); 27 | if (!tc.IsAbstract.HasValue) 28 | { 29 | result.Abstract = element._IsAbstract() && !element._IsInterface(); 30 | } 31 | else 32 | { 33 | result.Abstract = tc.IsAbstract.Value; 34 | } 35 | return result; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.GenericsExport3.cs: -------------------------------------------------------------------------------- 1 | using Reinforced.Typings.Fluent; 2 | using Xunit; 3 | 4 | namespace Reinforced.Typings.Tests.SpecificCases 5 | { 6 | class ExplicitGeneric 7 | { 8 | 9 | } 10 | 11 | class SomeOther 12 | { 13 | public ExplicitGeneric Prop { get; } 14 | 15 | public ExplicitGeneric Prop2 { get; } 16 | } 17 | public partial class SpecificTestCases 18 | { 19 | [Fact] 20 | public void GenericsExport3() 21 | { 22 | /* 23 | * Here we export type with materialized generics explicitly. So ExplicitGeneric becomes known type, but 24 | * generic definition ExpicitGeneric was exported differently so there are 2 different types 25 | */ 26 | 27 | const string result = @" 28 | export interface IExplicitGeneric 29 | { 30 | } 31 | export interface ISomeOther 32 | { 33 | Prop: IExplicitGeneric; 34 | Prop2: ICompletelyDifferentType; 35 | } 36 | export interface ICompletelyDifferentType 37 | { 38 | } 39 | "; 40 | 41 | AssertConfiguration(s => 42 | { 43 | s.Global(a => a.DontWriteWarningComment().UseModules()); 44 | s.ExportAsInterfaces(new[] 45 | { 46 | typeof(ExplicitGeneric), 47 | typeof(SomeOther), 48 | }, x => x.WithPublicProperties().WithPublicMethods()); 49 | s.ExportAsInterfaces(new [] {typeof(ExplicitGeneric<>)},d=>d.WithPublicProperties().OverrideName("CompletelyDifferentType")); 50 | }, result); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /Reinforced.Typings/Fluent/MemberBuilders/MemberExportBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using Reinforced.Typings.Attributes; 4 | // ReSharper disable CheckNamespace 5 | 6 | namespace Reinforced.Typings.Fluent 7 | { 8 | /// 9 | /// Fluent export configuration builder for Type Member 10 | /// 11 | public class MemberExportBuilder 12 | { 13 | internal TypeBlueprint _containingTypeBlueprint; 14 | internal readonly MemberInfo _member; 15 | internal TsTypedMemberAttributeBase _forMember; 16 | 17 | /// Initializes a new instance of the class. 18 | internal MemberExportBuilder(TypeBlueprint containingTypeBlueprint, MemberInfo member) 19 | { 20 | _containingTypeBlueprint = containingTypeBlueprint; 21 | if (member != null) 22 | { 23 | _member = member; 24 | _forMember = containingTypeBlueprint.ForMember(member,true); 25 | } 26 | } 27 | 28 | internal virtual bool IsIgnored 29 | { 30 | get { return _containingTypeBlueprint.IsIgnored(_member); } 31 | set 32 | { 33 | if (value) _containingTypeBlueprint.Ignored.Add(_member); 34 | else if (_containingTypeBlueprint.Ignored.Contains(_member)) _containingTypeBlueprint.Ignored.Remove(_member); 35 | } 36 | } 37 | 38 | internal virtual List Decorators 39 | { 40 | get { return _containingTypeBlueprint.DecoratorsListFor(_member); } 41 | } 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Reinforced.Typings/Fluent/TypeExtensions/TypeExportExtensions.All.NamesAndNamespaces.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable CheckNamespace 2 | namespace Reinforced.Typings.Fluent 3 | { 4 | /// 5 | /// Set of extensions for types exporting configuration 6 | /// 7 | public static partial class TypeExportExtensions 8 | { 9 | /// 10 | /// Overrides name of exported type 11 | /// 12 | /// Configuration 13 | /// Custom name to be used 14 | public static TypeExportBuilder OverrideName(this TypeExportBuilder conf, string name) 15 | { 16 | conf.Blueprint.TypeAttribute.Name = name; 17 | return conf; 18 | } 19 | 20 | /// 21 | /// Configures exporter do not to export member to corresponding namespace 22 | /// 23 | public static T DontIncludeToNamespace(this T conf, bool include = false) 24 | where T : TypeExportBuilder 25 | { 26 | conf.Blueprint.TypeAttribute.IncludeNamespace = include; 27 | return conf; 28 | } 29 | 30 | /// 31 | /// Configures exporter to export type to specified namespace 32 | /// 33 | /// Configuration 34 | /// Namespace name 35 | public static T OverrideNamespace(this T conf, string nameSpace) 36 | where T : TypeExportBuilder 37 | { 38 | conf.Blueprint.TypeAttribute.Namespace = nameSpace; 39 | return conf; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.ReferencesPart6ByDanielWest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 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 ReferencesPart6ByDanielWest() 12 | { 13 | /** 14 | * Specific test case with equal folder names by Daniel West 15 | */ 16 | 17 | const string file1 = @" 18 | export namespace Reinforced.Typings.Tests.SpecificCases { 19 | export enum SomeEnum { 20 | One = 0, 21 | Two = 1 22 | } 23 | }"; 24 | const string file2 = @" 25 | import * as Enum from '../../APIv2/Models/TimeAndAttendance/Enum'; 26 | 27 | export namespace Reinforced.Typings.Tests.SpecificCases { 28 | export class SomeViewModel 29 | { 30 | public Enum: Enum.Reinforced.Typings.Tests.SpecificCases.SomeEnum; 31 | } 32 | }"; 33 | 34 | AssertConfiguration(s => 35 | { 36 | s.Global(a => a.DontWriteWarningComment().UseModules(discardNamespaces: false)); 37 | 38 | s.ExportAsEnum().ExportTo("Areas/APIv2/Models/TimeAndAttendance/Enum.ts"); 39 | s.ExportAsClass().WithPublicProperties().ExportTo("Areas/Reporting/Models/Model.ts"); 40 | }, new Dictionary 41 | { 42 | { Path.Combine(TargetDir, "Areas/APIv2/Models/TimeAndAttendance/Enum.ts"), file1 }, 43 | { Path.Combine(TargetDir, "Areas/Reporting/Models/Model.ts"), file2 } 44 | }, compareComments: true); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/Reinforced.Typings.Tests.Dev.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | Preview 8 | 9 | 10 | 11 | w:\Work\Reinforced\Typings\Reinforced.Typings\Reinforced.Typings.Tests\Reinforced.Typings.Tests.Dev.xml 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | runtime; build; native; contentfiles; analyzers; buildtransitive 25 | all 26 | 27 | 28 | runtime; build; native; contentfiles; analyzers; buildtransitive 29 | all 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Reinforced.Typings/Ast/RtIdentifier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Reinforced.Typings.Ast 5 | { 6 | /// 7 | /// AST node for identifier name 8 | /// 9 | public class RtIdentifier : RtNode 10 | { 11 | /// 12 | /// Constructs new instance of AST node 13 | /// 14 | public RtIdentifier() 15 | { 16 | } 17 | 18 | /// 19 | /// Constructs new instance of AST node 20 | /// 21 | /// identifier name 22 | public RtIdentifier(string identifierName) 23 | { 24 | IdentifierName = identifierName; 25 | } 26 | 27 | /// 28 | /// Identifier name 29 | /// 30 | public string IdentifierName { get; set; } 31 | 32 | /// 33 | /// Is current identifier nullable 34 | /// 35 | public bool IsNullable { get; set; } 36 | 37 | /// 38 | public override IEnumerable Children 39 | { 40 | get { yield break; } 41 | } 42 | 43 | /// 44 | public override void Accept(IRtVisitor visitor) 45 | { 46 | visitor.Visit(this); 47 | } 48 | 49 | /// 50 | public override void Accept(IRtVisitor visitor) 51 | { 52 | visitor.Visit(this); 53 | } 54 | 55 | /// 56 | public override string ToString() 57 | { 58 | return IdentifierName + (IsNullable?"?":String.Empty); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Reinforced.Typings/Visitors/TypeScript/TypeScriptExportVisitor.RtFunction.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(RtFunction 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 | if (node.IsAsync) 17 | { 18 | Write("async "); 19 | } 20 | } 21 | Visit(node.Identifier); 22 | Write("("); 23 | SequentialVisit(node.Arguments, ", "); 24 | Write(") "); 25 | if (node.ReturnType != null) 26 | { 27 | Write(": "); 28 | Visit(node.ReturnType); 29 | } 30 | 31 | if (Context == WriterContext.Interface) 32 | { 33 | WriteLine(";"); 34 | } 35 | else 36 | { 37 | if (node.Body != null && !string.IsNullOrEmpty(node.Body.RawContent)) 38 | { 39 | CodeBlock(node.Body); 40 | } 41 | else 42 | { 43 | EmptyBody(node.ReturnType, node.IsAsync); 44 | } 45 | } 46 | 47 | if (!string.IsNullOrEmpty(node.LineAfter)) 48 | { 49 | AppendTabs(); 50 | Write(node.LineAfter); 51 | Br(); 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Samples/Difficult/Reinforced.Typings.Samples.Difficult.CodeGenerators/Scripts/angular-loader.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | AngularJS v1.4.8 3 | (c) 2010-2015 Google, Inc. http://angularjs.org 4 | License: MIT 5 | */ 6 | (function(){'use strict';function d(b){return function(){var a=arguments[0],e;e="["+(b?b+":":"")+a+"] http://errors.angularjs.org/1.4.8/"+(b?b+"/":"")+a;for(a=1;a 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | 7 | /// 8 | 9 | declare module "angular-sanitize" { 10 | var _: string; 11 | export = _; 12 | } 13 | 14 | /////////////////////////////////////////////////////////////////////////////// 15 | // ngSanitize module (angular-sanitize.js) 16 | /////////////////////////////////////////////////////////////////////////////// 17 | declare module angular.sanitize { 18 | 19 | /////////////////////////////////////////////////////////////////////////// 20 | // SanitizeService 21 | // see http://docs.angularjs.org/api/ngSanitize.$sanitize 22 | /////////////////////////////////////////////////////////////////////////// 23 | interface ISanitizeService { 24 | (html: string): string; 25 | } 26 | 27 | /////////////////////////////////////////////////////////////////////////// 28 | // Filters included with the ngSanitize 29 | // see https://github.com/angular/angular.js/tree/v1.2.0/src/ngSanitize/filter 30 | /////////////////////////////////////////////////////////////////////////// 31 | export module filter { 32 | 33 | // Finds links in text input and turns them into html links. 34 | // Supports http/https/ftp/mailto and plain email address links. 35 | // see http://code.angularjs.org/1.2.0/docs/api/ngSanitize.filter:linky 36 | interface ILinky { 37 | (text: string, target?: string): string; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Samples/Reinforced.Typings.Samples.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reinforced.Typings.Samples.Simple.Quickstart", "Simple\Reinforced.Typings.Samples.Simple.Quickstart\Reinforced.Typings.Samples.Simple.Quickstart.csproj", "{ABEAA485-7FE0-49CA-8F83-065BD767C2D1}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reinforced.Typings.Samples.Difficult.CodeGenerators", "Difficult\Reinforced.Typings.Samples.Difficult.CodeGenerators\Reinforced.Typings.Samples.Difficult.CodeGenerators.csproj", "{8014B424-7ADF-4FA3-8772-7271861B6CB3}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {ABEAA485-7FE0-49CA-8F83-065BD767C2D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {ABEAA485-7FE0-49CA-8F83-065BD767C2D1}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {ABEAA485-7FE0-49CA-8F83-065BD767C2D1}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {ABEAA485-7FE0-49CA-8F83-065BD767C2D1}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {8014B424-7ADF-4FA3-8772-7271861B6CB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {8014B424-7ADF-4FA3-8772-7271861B6CB3}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {8014B424-7ADF-4FA3-8772-7271861B6CB3}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {8014B424-7ADF-4FA3-8772-7271861B6CB3}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.CrozinSubstitutions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Reinforced.Typings.Ast.TypeNames; 3 | using Reinforced.Typings.Attributes; 4 | using Reinforced.Typings.Fluent; 5 | using Xunit; 6 | 7 | namespace Reinforced.Typings.Tests.SpecificCases 8 | { 9 | public partial class SpecificTestCases 10 | { 11 | #region Substitutions 12 | 13 | public class CrozinSubstitutionTest 14 | { 15 | public Guid GuidProperty { get; set; } 16 | 17 | public DateTime TimeProperty { get; set; } 18 | } 19 | 20 | public class CrozinLocalSubstitutionTest 21 | { 22 | public Guid OneMoreGuidProperty { get; set; } 23 | 24 | public DateTime OneMoreTimeProperty { get; set; } 25 | } 26 | 27 | #endregion 28 | 29 | [Fact] 30 | public void CrozinSubstitutions() 31 | { 32 | const string result = @" 33 | module Reinforced.Typings.Tests.SpecificCases { 34 | export interface ICrozinSubstitutionTest 35 | { 36 | GuidProperty: string; 37 | TimeProperty: any; 38 | } 39 | export interface ICrozinLocalSubstitutionTest 40 | { 41 | OneMoreGuidProperty: string; 42 | OneMoreTimeProperty: Date; 43 | } 44 | }"; 45 | AssertConfiguration(s => 46 | { 47 | s.Global(x => x.DontWriteWarningComment().ReorderMembers()); 48 | s.Substitute(typeof(Guid), new RtSimpleTypeName("string")); 49 | s.ExportAsInterface().WithPublicProperties(); 50 | s.ExportAsInterface() 51 | .WithPublicProperties() 52 | .Substitute(typeof(DateTime), new RtSimpleTypeName("Date")); 53 | }, result); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Reinforced.Typings/Fluent/MemberBuilders/MemberExportBuilder.EnumValue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using Reinforced.Typings.Attributes; 4 | // ReSharper disable CheckNamespace 5 | 6 | namespace Reinforced.Typings.Fluent 7 | { 8 | /// 9 | /// Fluent export configuration builder for enum value 10 | /// 11 | public class EnumValueExportBuilder 12 | { 13 | internal TypeBlueprint _containingTypeBlueprint; 14 | internal FieldInfo _member; 15 | 16 | /// Initializes a new instance of the class. 17 | internal EnumValueExportBuilder(TypeBlueprint containingTypeBlueprint, FieldInfo member) 18 | { 19 | _containingTypeBlueprint = containingTypeBlueprint; 20 | _member = member; 21 | } 22 | 23 | internal bool Ignore 24 | { 25 | get { return _containingTypeBlueprint.IsIgnored(_member); } 26 | set 27 | { 28 | if (value) _containingTypeBlueprint.Ignored.Add(_member); 29 | else if (_containingTypeBlueprint.Ignored.Contains(_member)) _containingTypeBlueprint.Ignored.Remove(_member); 30 | } 31 | } 32 | 33 | internal List Decorators 34 | { 35 | get { return _containingTypeBlueprint.DecoratorsListFor(_member); } 36 | } 37 | 38 | internal TsValueAttribute Attr 39 | { 40 | get { return _containingTypeBlueprint.ForEnumValue(_member,true); } 41 | } 42 | 43 | /// 44 | /// Gets value being configured 45 | /// 46 | public FieldInfo Member 47 | { 48 | get { return _member; } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Reinforced.Typings/Fluent/TypeExtensions/TypeExportExtensions.Enum.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 EnumExportBuilder WithCodeGenerator(this EnumExportBuilder conf) 13 | where T : ITsCodeGenerator 14 | { 15 | conf.Attr.CodeGeneratorType = typeof(T); 16 | return conf; 17 | } 18 | 19 | /// 20 | /// Turns enum to constant enum 21 | /// 22 | /// 23 | /// Enum configurator 24 | /// When true, "const enum" will be generated. Regular enum otherwise 25 | /// Fluent 26 | public static T Const(this T conf, bool isConst = true) where T : EnumExportBuilder 27 | { 28 | conf.Attr.IsConst = isConst; 29 | return conf; 30 | } 31 | 32 | /// 33 | /// Makes enum to use string initializer for its values (TypeScript 2.4) 34 | /// 35 | /// 36 | /// Enum configurator 37 | /// When true, enum values will be exported with string initializers 38 | /// Fluent 39 | public static T UseString(this T conf, bool useString = true) where T : EnumExportBuilder 40 | { 41 | conf.Attr.UseString = useString; 42 | return conf; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Samples/Simple/Reinforced.Typings.Samples.Simple.Quickstart/Views/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Reinforced.Typings/Attributes/TsAddTypeReference.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Reinforced.Typings.Ast.Dependency; 3 | 4 | namespace Reinforced.Typings.Attributes 5 | { 6 | /// 7 | /// This attribute is used to add reference directive to file containing single TS class typing. 8 | /// It is only used while splitting generated type sto different files 9 | /// 10 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum, AllowMultiple = true)] 11 | public class TsAddTypeReferenceAttribute : Attribute 12 | { 13 | /// 14 | /// Constructs new instance of TsAddTypeReferenceAttribute using referenced type 15 | /// 16 | /// Type reference 17 | public TsAddTypeReferenceAttribute(Type type) 18 | { 19 | Type = type; 20 | } 21 | 22 | /// 23 | /// Constructs new instance of TsAddTypeReferenceAttribute using referenced type 24 | /// 25 | /// Raw reference 26 | public TsAddTypeReferenceAttribute(string rawPath) 27 | { 28 | RawPath = rawPath; 29 | } 30 | 31 | /// 32 | /// Type that should be referenced 33 | /// 34 | public Type Type { get; set; } 35 | 36 | /// 37 | /// Raw reference path that will be added to target file 38 | /// 39 | public string RawPath { get; set; } 40 | 41 | private RtReference _reference; 42 | 43 | internal RtReference ToReference() 44 | { 45 | if (_reference == null) _reference = new RtReference() { Path = RawPath }; 46 | return _reference; 47 | } 48 | } 49 | } --------------------------------------------------------------------------------