Move To Roslyn #35 WIP#45
Conversation
There was a problem hiding this comment.
- Let's completely remove the dependency on NRefactory.
- Let's introduce continuous integration system (CI) appveyor.com.
- Taka look on config from PT.PM project.
|
|
||
| private List<string> _existingNames = new List<string>(); | ||
|
|
||
| private const int FirstSymbolCode = 97; |
There was a problem hiding this comment.
Use getting code from string literals. I mean int FirstSymbolCode = (int)'a';
Is it possible to use char instead of int everywhere?
| _options = options ?? new MinifierOptions(); | ||
| _identifierGenerator = new IdentifierGenerator(); | ||
| //Add cause MSBuild does not work without it | ||
| var _ = typeof(Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions); |
There was a problem hiding this comment.
Can you add a link where such behaviour explained?
There was a problem hiding this comment.
this decision is possible to avoid the exception of the type "The language 'C#' is not supported". Reason in the latest version of MSBuild, which does not load the required library, since it believes that it is not used in this program, although in fact it is applied.
There was a problem hiding this comment.
I mean add a website link with description to comment in the code.
| var document = _workspace.AddDocument(project.Id, "Doc", source); | ||
| _semanticModel = document.GetSemanticModelAsync().Result; | ||
| var newNode = _semanticModel.SyntaxTree.GetRoot(); | ||
| foreach (KeyValuePair<VariableDeclaratorSyntax, string> variable in _identifierGenerator.RenamedVariables) |
There was a problem hiding this comment.
Use more line breaks. At least insert line breaks before statements (if, foreach, while etc.).
| } | ||
|
|
||
| return newNode; | ||
| } |
There was a problem hiding this comment.
Move initialization stage to the separated method. Maybe Init.
|
|
||
| namespace CSharpMinifier.Rewriters | ||
| { | ||
| class CSharpRewriter : CSharpSyntaxRewriter |
There was a problem hiding this comment.
Specify the more specialized name for this class. This is not just a rewriter, but an identifier magnifier.
So, the better name is TokensMinifier or NamesMinifier.
| Options = options ?? new MinifierOptions(); | ||
| IgnoredIdentifiers = ignoredIdentifiers?.ToList() ?? new List<string>(); | ||
| IgnoredComments = ignoredComments?.ToList() ?? new List<string>(); | ||
| } |
There was a problem hiding this comment.
In this case, the method should take not only arrays but enumerables too.
After that use the following code:
IgnoredIdentifiers = ignoredIdentifiers as List<string> ?? ignoredIdentifiers?.ToList() ?? new List<string>();| { | ||
| public class RoslynMinifier : IMinifier | ||
| { | ||
| public SyntaxTree SyntaxTree { get; private set; } |
There was a problem hiding this comment.
It makes sense to remove this property and pass SyntaxTree to the method via arguments instead. Advantage: getting rid of yet another side effect.
| continue; | ||
| return fragment + lastChar; | ||
| } | ||
| return IncrementName(fragment) + Char.ConvertFromUtf32(FirstSymbolCode); |
There was a problem hiding this comment.
Try to rewrite this method in a more clear way:
- Get rid of recursion.
- Remove
Char.ConvertFromUtf32. It's possible to useToStringmethod here.
|
|
||
| public override SyntaxNode VisitFieldDeclaration(FieldDeclarationSyntax node) | ||
| { | ||
| if(_options.LocalVarsCompressing && node.Modifiers.Any(m => m.Value.Equals("private"))) |
| var _ = typeof(Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions); | ||
| } | ||
|
|
||
| public SyntaxNode VisitAndRename(SyntaxNode node) |
There was a problem hiding this comment.
I think the Visitor functionality doesn't matter in this case. Rename method to MinifyNames or MinifyNamesRecursive.
# Conflicts: # CSharpMinifier/IdentifierGenerator.cs # CSharpMinifier/Rewriters/TokensMinifier.cs
| <<<<<<< HEAD:CSharpMinifier/Rewriters/TokensMinifier.cs | ||
|
|
||
| ======= | ||
| >>>>>>> 5abeb53995ac7760de4ef050808dc751ceb38a2d:CSharpMinifier/Rewriters/CSharpRewriter.cs |
There was a problem hiding this comment.
What is it? Please resolve merge conflicts and fix build.
| _options = options ?? new MinifierOptions(); | ||
| _identifierGenerator = new IdentifierGenerator(); | ||
| //Add cause MSBuild does not work without it | ||
| var _ = typeof(Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions); |
There was a problem hiding this comment.
I mean add a website link with description to comment in the code.
| { | ||
| node = Visit(node); | ||
| return RenameAll(node); | ||
| foreach(var project in _workspace.CurrentSolution.Projects) |
There was a problem hiding this comment.
Please use whitespace before the parenthesis.
| (newNode, document) = Rename(nodeToSearch, document, variable.Value); | ||
| } | ||
|
|
||
| foreach(var method in _identifierGenerator.RenamedMethods) |
There was a problem hiding this comment.
Type name for a not obvious code.
|
Hi! What status of this request? 😄 How much work to fix? |
No description provided.