X Tutup
Skip to content

Commit d4907e3

Browse files
committed
Merge branch 'topics/undoredo'
2 parents dbb0b12 + b855013 commit d4907e3

File tree

330 files changed

+31787
-28753
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

330 files changed

+31787
-28753
lines changed
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.IO;
33
using System.Linq;
44
using System.Reflection;
@@ -7,57 +7,57 @@
77

88
namespace AssemblyImport.Tests
99
{
10-
public static class AssemblyGenerator
11-
{
12-
public static Assembly Generate(string sourceFile)
13-
{
14-
var code = ReadFile(sourceFile);
15-
var syntaxTree = CSharpSyntaxTree.ParseText(code);
16-
var assemblyName = Path.GetFileNameWithoutExtension(sourceFile);
17-
var assemblyPath = Path.Combine(Path.GetTempPath(), $"{assemblyName}.dll");
18-
19-
var references = new MetadataReference[]
20-
{
21-
MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
22-
MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location)
23-
};
10+
public static class AssemblyGenerator
11+
{
12+
public static Assembly Generate(string sourceFile)
13+
{
14+
var code = ReadFile(sourceFile);
15+
var syntaxTree = CSharpSyntaxTree.ParseText(code);
16+
var assemblyName = Path.GetFileNameWithoutExtension(sourceFile);
17+
var assemblyPath = Path.Combine(Path.GetTempPath(), $"{assemblyName}.dll");
18+
19+
var references = new MetadataReference[]
20+
{
21+
MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
22+
MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location)
23+
};
2424

25-
if (File.Exists(assemblyPath))
26-
{
27-
File.Delete(assemblyPath);
28-
}
25+
if (File.Exists(assemblyPath))
26+
{
27+
File.Delete(assemblyPath);
28+
}
2929

30-
using (var stream = File.Open(assemblyPath, FileMode.OpenOrCreate, FileAccess.Write))
31-
{
32-
var compilation = CSharpCompilation.Create(
33-
assemblyName,
34-
syntaxTrees: new[] { syntaxTree },
35-
references: references,
36-
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
37-
38-
var result = compilation.Emit(stream);
39-
if (!result.Success)
40-
{
41-
var failures = result.Diagnostics.Where(diagnostic =>
42-
diagnostic.IsWarningAsError ||
43-
diagnostic.Severity == DiagnosticSeverity.Error)
44-
.Select(diagnostic => new Exception($"{diagnostic.Id}: {diagnostic.GetMessage()}"))
45-
.ToArray();
30+
using (var stream = File.Open(assemblyPath, FileMode.OpenOrCreate, FileAccess.Write))
31+
{
32+
var compilation = CSharpCompilation.Create(
33+
assemblyName,
34+
syntaxTrees: new[] { syntaxTree },
35+
references: references,
36+
options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
37+
38+
var result = compilation.Emit(stream);
39+
if (!result.Success)
40+
{
41+
var failures = result.Diagnostics.Where(diagnostic =>
42+
diagnostic.IsWarningAsError ||
43+
diagnostic.Severity == DiagnosticSeverity.Error)
44+
.Select(diagnostic => new Exception($"{diagnostic.Id}: {diagnostic.GetMessage()}"))
45+
.ToArray();
4646

47-
throw new AggregateException(failures);
48-
}
49-
}
50-
51-
return Assembly.LoadFile(assemblyPath);
52-
}
47+
throw new AggregateException(failures);
48+
}
49+
}
50+
51+
return Assembly.LoadFile(assemblyPath);
52+
}
5353

54-
private static string ReadFile(string fileName)
55-
{
56-
var assembly = Assembly.GetExecutingAssembly();
57-
var baseDirectory = Path.GetDirectoryName(assembly.Location);
58-
var path = Path.Combine(baseDirectory, "Resources", fileName);
59-
60-
return File.ReadAllText(path);
61-
}
62-
}
63-
}
54+
private static string ReadFile(string fileName)
55+
{
56+
var assembly = Assembly.GetExecutingAssembly();
57+
var baseDirectory = Path.GetDirectoryName(assembly.Location);
58+
var path = Path.Combine(baseDirectory, "Resources", fileName);
59+
60+
return File.ReadAllText(path);
61+
}
62+
}
63+
}
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
using System.IO;
1+
using System.IO;
22
using System.Text;
33
using System.Xml;
44
using NClass.DiagramEditor.ClassDiagram;
55

66
namespace AssemblyImport.Tests
77
{
8-
public static class Extensions
9-
{
10-
public static string ToXml(this ClassDiagram diagram)
11-
{
12-
using (var stream = new MemoryStream())
13-
using (var reader = new StreamReader(stream))
14-
using (var writer = new XmlTextWriter(stream, Encoding.UTF8))
15-
{
16-
writer.Formatting = Formatting.Indented;
8+
public static class Extensions
9+
{
10+
public static string ToXml(this ClassDiagram diagram)
11+
{
12+
using (var stream = new MemoryStream())
13+
using (var reader = new StreamReader(stream))
14+
using (var writer = new XmlTextWriter(stream, Encoding.UTF8))
15+
{
16+
writer.Formatting = Formatting.Indented;
1717

18-
var doc = new XmlDocument();
19-
var root = doc.CreateElement("ProjectItem");
18+
var doc = new XmlDocument();
19+
var root = doc.CreateElement("ProjectItem");
2020

21-
doc.AppendChild(root);
22-
diagram.Serialize(root);
21+
doc.AppendChild(root);
22+
diagram.Serialize(root);
2323

24-
doc.Save(writer);
25-
stream.Seek(0, SeekOrigin.Begin);
24+
doc.Save(writer);
25+
stream.Seek(0, SeekOrigin.Begin);
2626

27-
return reader.ReadToEnd();
28-
}
29-
}
30-
}
31-
}
27+
return reader.ReadToEnd();
28+
}
29+
}
30+
}
31+
}
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NClass.AssemblyImport;
1+
using NClass.AssemblyImport;
22
using NClass.CSharp;
33
using NClass.DiagramEditor.ClassDiagram;
44
using NReflect.Filter;
@@ -9,40 +9,40 @@
99

1010
namespace AssemblyImport.Tests
1111
{
12-
[TestFixture]
13-
[Apartment(ApartmentState.STA)]
14-
public class NETImportTests
15-
{
16-
[TestCase("ImportDefault.cs")]
17-
[TestCase("ImportMethods.cs")]
18-
[TestCase("ImportProperties.cs")]
19-
[TestCase("ImportEvents.cs")]
20-
[TestCase("ImportFields.cs")]
21-
[TestCase("ImportOperators.cs")]
22-
public void ImportFromSource(string fileName)
23-
{
24-
var assembly = AssemblyGenerator.Generate(fileName);
25-
var settings = GetDefaultSettings();
26-
var diagram = new ClassDiagram(CSharpLanguage.Instance);
27-
var importer = new NETImport(diagram, settings);
12+
[TestFixture]
13+
[Apartment(ApartmentState.STA)]
14+
public class NETImportTests
15+
{
16+
[TestCase("ImportDefault.cs")]
17+
[TestCase("ImportMethods.cs")]
18+
[TestCase("ImportProperties.cs")]
19+
[TestCase("ImportEvents.cs")]
20+
[TestCase("ImportFields.cs")]
21+
[TestCase("ImportOperators.cs")]
22+
public void ImportFromSource(string fileName)
23+
{
24+
var assembly = AssemblyGenerator.Generate(fileName);
25+
var settings = GetDefaultSettings();
26+
var diagram = new ClassDiagram(CSharpLanguage.Instance);
27+
var importer = new NETImport(diagram, settings);
2828

29-
importer.ImportAssembly(assembly.Location, useNewAppDomain: false).ShouldBeTrue();
30-
diagram.ToXml().ShouldMatchApproved(config => config.WithDescriminator(fileName));
31-
}
29+
importer.ImportAssembly(assembly.Location, useNewAppDomain: false).ShouldBeTrue();
30+
diagram.ToXml().ShouldMatchApproved(config => config.WithDescriminator(fileName));
31+
}
3232

33-
private static ImportSettings GetDefaultSettings()
34-
{
35-
return new ImportSettings
36-
{
37-
Name = "<last used>",
38-
CreateAssociations = true,
39-
CreateGeneralizations = true,
40-
CreateNestings = true,
41-
CreateRealizations = true,
42-
CreateRelationships = true,
43-
LabelAggregations = true,
44-
FilterRules = new List<FilterRule> { new FilterRule(FilterModifiers.AllModifiers, FilterElements.AllElements) }
45-
};
46-
}
47-
}
48-
}
33+
private static ImportSettings GetDefaultSettings()
34+
{
35+
return new ImportSettings
36+
{
37+
Name = "<last used>",
38+
CreateAssociations = true,
39+
CreateGeneralizations = true,
40+
CreateNestings = true,
41+
CreateRealizations = true,
42+
CreateRelationships = true,
43+
LabelAggregations = true,
44+
FilterRules = new List<FilterRule> { new FilterRule(FilterModifiers.AllModifiers, FilterElements.AllElements) }
45+
};
46+
}
47+
}
48+
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
namespace AssemblyImport.Tests
1+
namespace AssemblyImport.Tests
22
{
3-
public static class Project
4-
{
5-
public static void Main()
6-
{ }
7-
}
8-
}
3+
public static class Project
4+
{
5+
public static void Main()
6+
{ }
7+
}
8+
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
1+
using System;
22

33
namespace AssemblyImport.Tests
44
{
5-
public class ImportEvents
6-
{
7-
public event EventHandler<EventArgs> OnClick;
8-
}
9-
}
5+
public class ImportEvents
6+
{
7+
public event EventHandler<EventArgs> OnClick;
8+
}
9+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
namespace AssemblyImport.Tests
1+
namespace AssemblyImport.Tests
22
{
3-
public class ImportFields
4-
{
5-
public int field1;
6-
private volatile int field2;
7-
private static int field3;
8-
}
9-
}
3+
public class ImportFields
4+
{
5+
public int field1;
6+
private volatile int field2;
7+
private static int field3;
8+
}
9+
}
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
namespace AssemblyImport.Tests
1+
namespace AssemblyImport.Tests
22
{
3-
public class ImportMethods
4-
{
5-
static ImportMethods() {}
3+
public class ImportMethods
4+
{
5+
static ImportMethods() {}
66

7-
ImportMethods(int val) {}
8-
private ImportMethods(int value1, int value2) { }
7+
ImportMethods(int val) {}
8+
private ImportMethods(int value1, int value2) { }
99

10-
int Method1(System.Tuple<int, int?>[] array, out int value)
11-
{
12-
value = 0;
13-
return 1;
14-
}
10+
int Method1(System.Tuple<int, int?>[] array, out int value)
11+
{
12+
value = 0;
13+
return 1;
14+
}
1515

16-
System.Collections.Generic.IEnumerable<System.Tuple<System.ConsoleKey, System.ConsoleKey?>> Method2()
17-
{
18-
return null;
19-
}
16+
System.Collections.Generic.IEnumerable<System.Tuple<System.ConsoleKey, System.ConsoleKey?>> Method2()
17+
{
18+
return null;
19+
}
2020

21-
void Method3(System.Collections.Generic.IEnumerable<System.Tuple<System.ConsoleKey, System.ConsoleKey?>> src)
22-
{ }
21+
void Method3(System.Collections.Generic.IEnumerable<System.Tuple<System.ConsoleKey, System.ConsoleKey?>> src)
22+
{ }
2323

24-
~ImportMethods() { }
25-
}
26-
}
24+
~ImportMethods() { }
25+
}
26+
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
namespace AssemblyImport.Tests
1+
namespace AssemblyImport.Tests
22
{
3-
public class ImportOperators
4-
{
5-
public static ImportOperators operator+ (ImportOperators first, ImportOperators second)
6-
{
7-
return new ImportOperators();
8-
}
3+
public class ImportOperators
4+
{
5+
public static ImportOperators operator+ (ImportOperators first, ImportOperators second)
6+
{
7+
return new ImportOperators();
8+
}
99

10-
public static implicit operator ImportOperators(int value)
11-
{
12-
return new ImportOperators();
13-
}
14-
}
15-
}
10+
public static implicit operator ImportOperators(int value)
11+
{
12+
return new ImportOperators();
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)
X Tutup