-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit definition files via DLL and without source code #41
Comments
This pack introduced the ability to generate the signature AST from an assembly to be used for generating definition files in future without the need for code, just the assembly. Targets #41
A problem occurs in terms of API after this will be completed: 3 ways will be available for generating definition files:
ScenariosScenario-wise, we have conflicts as we need to serve the following ones:
When both assembly and source are available, we fall in the second scenario, thus the code is not really necessary. Only possible difference might be the code structure. Deprecation requiredIdeally, we need to deprecate API for possibility no. 2. This has to be considered in the future. Current solutionThe 3 different strategies will be triggered as follows:
|
Tests added by extending the build task example project. Extended runner in ScriptSharp for keeping into account the assembly. Attention: The runner does not work because the assembly is not loaded into the inspection only context and all reference errors are surfacing. This must be fixed in later pack. Targets #41
Assebly now correctly loaded. Also added IAssemblyLoader for abstracting loading capabilities. Targets #41
Problems encountered for loading assemblies and deps:
Mono.cecilBecause of all the issues encountered so far, it has been decided to take a dependency on Mono.cecil. |
This change modifies a little the architecture around Reflection. - Using Mono.Cecil for reflecting assemblies - Added assembly abstraction layer in order to limit the use of Cecil to one single project only (avoiding dep spreading across the product and tests) - Added layer for assembly loading strategies Verified that assemblies are correctly loaded without any need to load external dependencies on that one. IL parsing executed fine and attribute info available. Unfortunately `System.Reflection` triggers many problems: - If the assembly is loaded in reflection-only-context, custom-attributes are not available. - In order to have custom-attributes available, tried loading assembly in normal exec context. Failure occurs as the assembly references other assemblies (`mscorlib` and `Script.Import.dll`) which cannot be found.
Introduding support for object creation expressions with renderers and tests targeting the most basic scenario: parameterless object construction. This is related to #41 as the generation of the AST in `ASTBuilder` needs the creation of empty block codes where we emit `throw new NotImplementedException()`. SO far the object creation expression was not supported, thus leading to issues here.
Helper method `BaseTypeReference.Name` was returning sometimes the type full name. This was interfering with `SeparateClassAndInterfacesBasedOnNames` as the routine expects pure names, no namespaces. Applied namespace stripping. Targets #41
The ScriptSharp definitino generator with reflection is using the normal ASTWalker, it must use the ScriptSharpDefinitionASTWalker instead. Rewired. Targets #41
When generating the AST in Reflection, the System.Object base class should be ignored. Targets #41
The generation of AST from assembly was failing because the semantic model was computed on the original assembly. Because of the ScriptNamespace, the AST generator will change the AST from the original one in the assembly, this was causing a misalignment in the semantic model being used and, at AST walking time, the ScriptNamespace attribute was detected wrongly. Fixed the issue and also got rid of the raw assembly in reflcetion. Targets #41
Class AST node factory was ignoring constructors. Added support and added tests too. Targets #41
Interfaces in ScriptSharp definition generation are not emitted at full! Only the interface name and base list. Targets #41
Since Mono.Cecil parses IL, getters and setters are seen as methods. Filter them out in factories and proxies. Targets #41
Properties were not supported. Adding it with tests. Targets #41
Reflection to support enums. Added tests. Targets #41
BugThe generated code correctly defines type in overridden namespaces but references to those types still use the old namespace. Root causeThe issue is in factories. |
The ScriptSharp definition reflector was not building the correst AST as type references were not considering the ScriptNamespace override. Only definition of types were, but references to types were using the original full name, Targets #41
Rosetta ScriptSharp Definition Generator can work on DLLs only instead of using source files.
Scenarios
Can be used in contexts where:
Benefits
Can cut down dependencies on code.
Downsides
Comments and documentation not available for emitting.
Plan
It is necessary to decouple the ScriptSharp generation components from AST Walkers as not needed. Also more work needed:
SemanticModel
.SemanticModel
, here we might get issues as helpers are depending onSyntaxNode
sTranslationUnit
s as they areImportant Evaluate the possibility to generate AST and then feed it to the regular stack.
The text was updated successfully, but these errors were encountered: