Closed mwpowellhtx closed 6 years ago
For instance, what in the world does bool ascendOutOfTrivia
mean? And why does it default to true
?
How would I identify the Ancestors
? i.e. parent classes, particularly those that are Generic in nature.
So my lineage looks something like this:
class Tool {}
class Tool<T> : Tool where T : Tool<T> {}
And I would be decorating a class that looked something like this:
class MyTool : Tool<MyTool> {}
And I want to be able to vet whether MyTool
was indeed of the expected lineage, Tool
, Tool<T>
, and so on, before doing anything further.
Thanks!
It's turning out this may be a non-starter until the migration path can be resolved.
Specifically, I want to generate some boilerplate operator overloads for the target classes in question, i.e. using OperatorKind
, but I do not see this type referenced in the assemblies which could be added as NuGet reference to my project.
Is there another NuGet package I need to facilitate this?
The whole domain you're asking about is Roslyn API. This repo is only a tool that uses Roslyn API and allows code generation. We won't answer questions about Roslyn API here. Please refer to it's documentation.
Roslyn is Microsoft.CodeAnalysis
namespace. It's a C# compiler platform. Repo is here: https://github.com/dotnet/roslyn
Roslyn docs: https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
Of course, fair enough. My concern as re: CodeGeneration.Roslyn
is that it seems to be out of date with the latest Roslyn, so I'm not sure I can leverage Roslyn CodeAnalysis to gen the code I'd like to gen.
My goal is to analyze for target Class
, determine whether it is decorated with a known Attribute
, and gen a Partial Class
by the same name with some helpful overloaded operators, which in turn invoke available Base Class
methods. There are a couple of nuances there, I expect, such as alignment within namespaces, responding to refactor requests, class renaming, etc, but which are more Roslyn
related than CodeGeneration
.
However, I'm finding that perhaps Operator Declaration is a feature that may have been recently added, and the best I could reference without errors is 0.4.11
. The latest is 0.4.42
, but this would not install on account of incompatibility with Framework 4.6.2
, apparently. And 0.4.37
was altogether broken, involving some broken references during dependency resolution.
My context is VS2015
targeting Framework 4.6.2
at the moment. Should I be tarting Framework 4.7.x
instead for this to be considered up to date? Please advise...
I'm not going to deeply analyze your problem (it's not my project), I can only suggest you looking at my Code Generator implementation: https://github.com/amis92/RecordGenerator
Also, Roslyn v2.2.0 (which is what v0.4.42 references) surely supports operators, it's been a fully working C# compiler since v1.0. You just need to search harder, and experiment. It's really all I can say in this matter.
@amis92 Thanks for the feedback. Sure, but the documentation is sparse, at best. Needs more elaboration. I'm following up with the Roslyn team along these lines, at any rate. That said, I'll have a look at RecordGenerator
. Thanks!
Updating the Roslyn version used by this project should be fine, FWIW.
Okay, I'd like to glean more details about a class. Based on the front facing example, I can at least tell if I'm dealing with a
Class
definition. However, how do I determine if it isPartial
, what it's lineage is, i.e. what are its parent(s), etc?Some documentation around methods in general, i.e.
Ancestors
, would be helpful as well, I think. It means the difference between posting questions here and having the answers there in reference.Thanks!