Comments (8)
Thank you for your feedback
Unfortunately you caught me just before I travel for four days, so it will probably be this weekend before I can address this. My apologies.
Namespace nesting is a challenge - I believe I have an open issue on this and do plan to solve it.
Whitespace is another challenge for me, but this is a bug and I'll record it as such.
I will check on the missing Get/Set and public keyword. Obviously bugs, not sure what happened here.
I plan another attack (rewrite) on the whitespace issue. At present, I see reformatting with the VS rules as the best alternative for new code, but ideally it would preserve existing code.
Thank you again for your feedback, and let me know after I update for these changes whether you see anything else. As well, I'll add your code as a unit test to ensure problems don't recur.
Kathleen
from roslyndom.
(2) No space between type and field name
When items are created by constructors other than those designed for factories, the NeedsFormatting value is not set to true.
Other whitespace issues remain and a more complex solution and/or a way to explicitly set formatting in a simple way, and if that is done, doing this at output via NeedsFormatting may become a problem.
from roslyndom.
(4) No public keyword
The constructor was setting the AccessModifier instead of the DeclaredAccessModifier. The DeclaredAccessModifier properties now also set the AccessModifier
Note, I changed the parameter name to declaredAccessModifier, which is a breaking change. I did think about the pain of this change, but decided it should not be misleading which value is being set.
from roslyndom.
(3) No get/set block on property
A property created without specifying any accessors will be a read/write auto-property.
There were actually several issues changed behind this
- CanGet/CanSet properties are calculated based on the presence of a Set or Get Accessor
- CanGet/CanSet parameters on properties changed to IsReadOnly/IsWriteOnly because they do not parallel the CanGet/CanSet properties. These are used in determining whether to build the setter/getter
- A bug in AccessorType usage in Accessors was fixed
- A bug in statement usage in Accessors was fixed
- A new overload doesn't require a name - names are only meaningful for some event accessors
from roslyndom.
(5) Missing ";" after property (although it wouldn't be needed if there were a get/set block
This is automatically fixed by fixing 3
from roslyndom.
*** Can you explain what goal you wanted here ****
Specifically, the fix I made ignores your field. Do you want a property constructor that takes a field and uses it as the backing field? How would this work with your "StringField"? Do you have an implicit conversion?
from roslyndom.
(6) The formatting is a bit rough
Yes, it is rough. Formatting/whitespace is the bane of my existence.
You're correct that you need an easy answer, so I'm adding a new method called GetFormattedSourceCode which you would use like this:
var formatted = RDom.CSharp.GetFormattedSourceCode(root);
which results in
using RoslynDom.Common;
namespace Company
{
namespace Core
{
public class Product
{
private StringField mRevisions;
public virtual string Revisions { private get; private set; }
}
}
}
from roslyndom.
(1) Nested namespaces, while OK, were unexpected
Internally, namespaces are held as single parts - this is because there is no difference between the following:
namespace A.B {}
namespace A { namespace B{} }
However, we humans like what we like, so the namespaces in input code will be preserved via a "GroupGuid" (the same approach will later be taken for other grouping locations, see issue #53 ). If adding new namespaces, the GroupGuid can also be used for combining.
The final test for all these issues is:
[TestMethod]
public void Issue_88_generated_class_results_in_uncompilable_code()
{
var csharpCode = @"using RoslynDom.Common;
namespace Company.Core
{
public class className
{
}
}";
IRoot root = RDom.CSharp.Load(csharpCode);
var firstClass = root.RootClasses.First();
firstClass.Name = "Product";
var backerField = new RDomField(name: "mRevisions", returnTypeName: "StringField");
firstClass.AddOrMoveMember(backerField);
var property = new RDomProperty(name: "Revisions", propertyTypeName: "string", declaredAccessModifier: AccessModifier.Public, isVirtual: true);
firstClass.AddOrMoveMember(property);
var formatted = RDom.CSharp.GetFormattedSourceCode(root);
var expected = "using RoslynDom.Common;\r\nnamespace Company.Core\r\n{\r\n public class Product\r\n {\r\n private StringField mRevisions;\r\n public virtual string Revisions { private get; private set; }\r\n }\r\n}";
Assert.AreEqual(expected, formatted);
}
and the final output:
using RoslynDom.Common;
namespace Company.Core
{
public class Product
{
private StringField mRevisions;
public virtual string Revisions { private get; private set; }
}
}
Thank you again for your input!!!!
from roslyndom.
Related Issues (20)
- Assemblies shouldn't be loaded from app domain's base path HOT 2
- Invalid code isn't handled correctly HOT 2
- InvalidCastException when using RDom.CSharp.LoadGroup HOT 1
- Status of project? Still alpha? HOT 1
- Need to update to the beta of The .NET Compiler Platform to the Halloween build
- Should BuildSyntax() be changed to GetSyntax()
- Redesign Factory Lookup
- Support for lambda expressions HOT 1
- Try to retrieve anonymous method parameter types from Roslyn
- RequestedValue could have parameter that searched up tree
- Expression construction (not parsed) messed up
- Crash if Region at end of file
- Region fails if multiple in same parent
- Multipart namespaces break regions
- Crashes when encountering interpolated strings HOT 2
- Empty region causes NullReferenceException HOT 2
- Probable typo in RDomParameter HOT 1
- Validate input to symbol names are valid symbols
- Support non-semantically (randomly placed) regions 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 roslyndom.