TsExport exporting settings
    public static void Generate()
    {
        var assemblies = CompilationPipeline.GetAssemblies(AssembliesType.PlayerWithoutTestAssemblies)
                         .Select(m =>
        {
            var path = Path.Combine(Directory.GetCurrentDirectory(), m.outputPath);
            try
            {
                return(System.Reflection.Assembly.LoadFile(path));
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to load: " + path);
                Debug.LogException(e);
                return(null);
            }
        })
                         .Where(m => m != null)
                         .ToArray();

        var context = new Reinforced.Typings.ExportContext(assemblies)
        {
            ConfigurationMethod = Configure,
            TargetFile          = "../../src/unity.ts",
        };

        context.Global.UseModules             = true;
        context.Global.ExportPureTypings      = false;
        context.Global.UnresolvedToUnknown    = false;
        context.Global.GenerateDocumentation  = true;
        context.Global.AutoOptionalProperties = true;

        new TsExporter(context).Export();
    }
 /// <summary>
 ///     Constructs new type resolver
 /// </summary>
 internal TypeResolver(ExportContext context, ExportedFile file, ReferenceInspector refInspector)
 {
     _context      = context;
     _file         = file;
     _refInspector = refInspector;
 }
 internal Location(ExportContext exContext)
 {
     _exContext = exContext;
 }
 private ITsCodeGenerator <T> LazilyInstantiateGenerator <T>(Type generatorType, ExportContext context)
 {
     lock (_generatorsCache)
     {
         if (!_generatorsCache.ContainsKey(generatorType))
         {
             try
             {
                 _generatorsCache[generatorType] = Activator.CreateInstance(generatorType);
                 var gen = (ITsCodeGenerator <T>)_generatorsCache[generatorType];
                 gen.Context = context;
             }
             catch (Exception ex)
             {
                 ErrorMessages.RTE0003_GeneratorInstantiate.Throw(generatorType.FullName, ex.Message);
             }
         }
         return((ITsCodeGenerator <T>)_generatorsCache[generatorType]);
     }
 }
 /// <summary>
 ///     Retrieves code generator for namespaces
 /// </summary>
 /// <returns></returns>
 public NamespaceCodeGenerator GeneratorForNamespace(ExportContext context)
 {
     _defaultNsgenerator.Context = context;
     return(_defaultNsgenerator);
 }
Exemple #6
0
 /// <summary>
 ///     Constructs new instance of TypeScript exporter
 /// </summary>
 /// <param name="context"></param>
 public TsExporter(ExportContext context)
 {
     _context = context;
 }
Exemple #7
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Object" /> class.</summary>
 internal ExportedFile(HashSet <Type> typesToExport, string fileName, InspectedReferences references, ExportContext context)
 {
     _context             = context;
     TypesToExport        = typesToExport;
     FileName             = fileName;
     AllTypesIsSingleFile = !_context.Hierarchical;
     References           = references;
     TypeResolver         = new TypeResolver(this);
     AddReferencesFromTypes();
 }
 /// <summary>
 ///     Constructs new instance of TypeScript exporter
 /// </summary>
 /// <param name="context"></param>
 public TsExporter(ExportContext context)
 {
     _context = context;
     _fileOps = new FilesOperations(context);
 }