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();
    }
Exemplo n.º 2
0
 /// <summary>
 ///     Constructs new type resolver
 /// </summary>
 internal TypeResolver(ExportContext context, ExportedFile file, ReferenceInspector refInspector)
 {
     _context      = context;
     _file         = file;
     _refInspector = refInspector;
 }
Exemplo n.º 3
0
 internal Location(ExportContext exContext)
 {
     _exContext = exContext;
 }
Exemplo n.º 4
0
 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]);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 ///     Retrieves code generator for namespaces
 /// </summary>
 /// <returns></returns>
 public NamespaceCodeGenerator GeneratorForNamespace(ExportContext context)
 {
     _defaultNsgenerator.Context = context;
     return(_defaultNsgenerator);
 }
Exemplo n.º 6
0
 /// <summary>
 ///     Constructs new instance of TypeScript exporter
 /// </summary>
 /// <param name="context"></param>
 public TsExporter(ExportContext context)
 {
     _context = context;
 }
Exemplo n.º 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();
 }
Exemplo n.º 8
0
 /// <summary>
 ///     Constructs new instance of TypeScript exporter
 /// </summary>
 /// <param name="context"></param>
 public TsExporter(ExportContext context)
 {
     _context = context;
     _fileOps = new FilesOperations(context);
 }