Comments (11)
This might be a good starting point: https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/how-to-load-assemblies-into-the-reflection-only-context
from dotnet.
Thanks! The existing TypeBasedComponentFinderStrategy needs to continue to exist, because a number of existing users are stuck on .NET 4, which doesn't have access to Roslyn. But we could certainly create an additional strategy that uses Roslyn. I'm just finishing off some tweaks to the Structurizr for Java version, and will start work again on the .NET version very soon (there are some major features now missing; e.g. documentation and deployment diagrams).
from dotnet.
I actually started taking a look at using Mono.Cecil for analysis last night, although I didn't get too far. The nice thing about it is that it is still available for .NET 4.0 and apparently works faster than built-in .NET reflection. I'll keep on it after work today.
from dotnet.
Cecil might be the best option for maintaining support for older framework versions but it'd be a breaking change since Cecil's type metadata classes don't inherit from the abstract base types within .NET itself. Because of that, Component
would need to have a public change for the TypeObject
property and then through almost everything in the Analysis namespace (ComponentFinder
and the abstract base ComponentFinderStrategy
are the only reflection-agnostic types).
I think it'd be good to go through with this, but given the weight of the change I don't feel that it'd be appropriate to just do the work and PR it up without some discussion first.
from dotnet.
I've just started making some changes to the reflections-based analysis code (porting the changes I made to the Java version) and I don't think that TypeObject property is actually needed any more. :-)
from dotnet.
Well, it does get used in TypeBasedComponentFinderStrategy.FindDependencies
but a move away from .NET reflection to Cecil or Roslyn would require that entire function to be rewritten anyway. I saw that the Model class would set the property as well but that's not really using it, heh.
from dotnet.
Are there further changes coming? Looks like there are still dependencies on reflection with ITypeMatcher and TypeRepository still using System.Type instead of CodeElement.
from dotnet.
I had a play with the reflection only loading and it doesn't quite work as well as simply loading the assemblies. I'm happy to split out the reflection code from the Structurizr.Core assembly so that you can implement a Cecil or Roslyn ComponentFinderStrategy. Thoughts?
from dotnet.
That might be a good idea, but ITypeMatcher I think should still eschew the use of System.Type so that its implementors could be used by the Cecil based strategy I'm considering, instead of needing to duplicate them.
from dotnet.
I've done the refactoring and the Structurizr.Core library can now be targeted at .NET Standard 1.3 (there were a few other .NET Framework dependencies that needed removing in addition to the reflection code). It should now be possible to use the Structurizr.Core library with UWP projects and create an implementation of the ComponentFinderStrategy that doesn't use reflection.
from dotnet.
Okay. I'll update what I've done probably some time on Saturday. I ended up creating a new project for a Cecil based analysis implementation that includes the full feature set of the reflection based analysis, although every type includes Cecil
somewhere in the name which feels kind of gross.
I see three possibilities for "normalizing" the type naming for the analysis implementations. The first, which is easiest, would be to match Cecil
in the type names in the Cecil implementation with Reflection
in the reflection implementation. The second would be to move the reflection types to a new Structurizr.Analysis.Reflection
namespace and the Cecil ones to Structurizr.Analysis.Cecil
and have them share the same common names.
The third, which would be the most work, would be to create an abstract class for type data as provided by any particular reflection system (.NET reflection, Cecil, Roslyn, etc.) and create adapters for the type data classes from each system. That way, it might be possible to simply provide a concrete repository and adapter for each system.
I favour the third option for the long run, but either of the first two would probably be best for now.
from dotnet.
Related Issues (20)
- problem HOT 1
- Default RankDirection not being serialized HOT 7
- EnableAutomaticLayout not working HOT 2
- dsl to C# serializer HOT 1
- EnableAutomaticLayout per default
- DefaultLayoutMergeStrategy breaks in certain scenarios HOT 4
- How can I model linked workspaces via CLI? HOT 2
- Exporting/embedding private workspace diagrams HOT 3
- Terraform support HOT 3
- Can't remove elements from model HOT 3
- Provide working example of loading layout information from an existing workspace.json HOT 1
- hi HOT 2
- Any chance for a dsl parser in c#? HOT 1
- Please make the archive-file optional HOT 3
- QUESTION: Will DSL be supported, will PutWorkspace keep working when workspace is deprecated? HOT 3
- the uploaded workspace of 0.54MB exceeds the size limit of 0.50MB HOT 3
- .net client won't preserve view custom size HOT 1
- Relationship between Person and Container not showing HOT 4
- Control RelationshipStyle on Dynamic View HOT 1
- Include mode on Filtered Views not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotnet.