forked from Xariman/SimpleSourceProtector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsingRewriter.cs
More file actions
31 lines (27 loc) · 979 Bytes
/
Copy pathUsingRewriter.cs
File metadata and controls
31 lines (27 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.Collections.Generic;
namespace SimpleSourceProtector
{
public class UsingRewriter : CSharpSyntaxRewriter
{
private readonly SemanticModel SemanticModel;
private List<UsingDirectiveSyntax> m_temp = new List<UsingDirectiveSyntax>();
public UsingRewriter(SemanticModel semanticModel) : base(true)
{
this.SemanticModel = semanticModel;
}
public override SyntaxNode VisitUsingDirective(UsingDirectiveSyntax node)
{
m_temp.Add(node);
return null;
}
public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
{
SyntaxList<UsingDirectiveSyntax> list = new SyntaxList<UsingDirectiveSyntax>();
list = list.AddRange(m_temp);
return node.WithUsings(list);
}
}
}