Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
공백 변경 숨기기
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
텍스트 스타일
모양 변경
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
Untitled diff
생성일
8년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
3 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
52 행
복사
17 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
60 행
복사
using System;
using System;
using System.IO;
using System.IO;
using System.Linq;
using System.Linq;
using System.Reflection;
using System.Reflection;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp;
class Program
class Program
{
{
static void Main(string[] args)
static void Main(string[] args)
{
{
var greetings = HelloWorlder.GetGreetings();
var greetings = HelloWorlder.GetGreetings();
// should write Hello World
// should write Hello World
greetings();
greetings();
}
}
}
}
public static class HelloWorlder
public static class HelloWorlder
{
{
public static Action GetGreetings()
public static Action GetGreetings()
{
{
var tree = CSharpSyntaxTree.ParseText(@"
var tree = CSharpSyntaxTree.ParseText(@"
using System;
using System;
public class MyClass
public class MyClass
{
{
public static void Main()
public static void Main()
{
{
복사
복사됨
복사
복사됨
Console.WriteLine(""Hello World!"");
//
Console.WriteLine(""Hello World!"");
Console.ReadLine();
//
Console.ReadLine();
}
}
}");
}");
const string testAsmName = "testLib";
const string testAsmName = "testLib";
var coreDir = Path.GetDirectoryName(typeof(object).GetTypeInfo().Assembly.Location);
var coreDir = Path.GetDirectoryName(typeof(object).GetTypeInfo().Assembly.Location);
복사
복사됨
복사
복사됨
var mscorlib = MetadataReference.CreateFromFile(Path.Combine(coreDir, "
mscorlib
.dll"));
var mscorlib = MetadataReference.CreateFromFile(Path.Combine(coreDir, "
System.Private.CoreLib
.dll"));
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary);
var compilation = CSharpCompilation.Create(testAsmName,
var compilation = CSharpCompilation.Create(testAsmName,
복사
복사됨
복사
복사됨
syntaxTrees: new[] { tree }, references: new[] { mscorlib }
);
syntaxTrees: new[] { tree }, references: new[] { mscorlib }
, options: options
);
복사
복사됨
복사
복사됨
var emitResult = compilation.Emit(
$"{testAsmName}.dll"
);
var ms = new MemoryStream();
var emitResult = compilation.Emit(
ms);
ms.Seek(0, SeekOrigin.Begin
);
if (!emitResult.Success)
if (!emitResult.Success)
{
{
throw new Exception(string.Join(Environment.NewLine, emitResult.Diagnostics.Select((x, i) => $"{i + 1}. {x}")));
throw new Exception(string.Join(Environment.NewLine, emitResult.Diagnostics.Select((x, i) => $"{i + 1}. {x}")));
}
}
복사
복사됨
복사
복사됨
var ourAssembly = Assembly.Load(
new AssemblyName(testAsmName
));
var ourAssembly = Assembly.Load(
ms.ToArray(
));
var type = ourAssembly.GetType("MyClass");
var type = ourAssembly.GetType("MyClass");
var meth = type.GetRuntimeMethod("Main", Type.EmptyTypes);
var meth = type.GetRuntimeMethod("Main", Type.EmptyTypes);
복사
복사됨
복사
복사됨
ms.Close();
return () => meth.Invoke(null, null);
return () => meth.Invoke(null, null);
}
}
}
}
저장된 비교 결과
원본
파일 열기
using System; using System.IO; using System.Linq; using System.Reflection; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; class Program { static void Main(string[] args) { var greetings = HelloWorlder.GetGreetings(); // should write Hello World greetings(); } } public static class HelloWorlder { public static Action GetGreetings() { var tree = CSharpSyntaxTree.ParseText(@" using System; public class MyClass { public static void Main() { Console.WriteLine(""Hello World!""); Console.ReadLine(); } }"); const string testAsmName = "testLib"; var coreDir = Path.GetDirectoryName(typeof(object).GetTypeInfo().Assembly.Location); var mscorlib = MetadataReference.CreateFromFile(Path.Combine(coreDir, "mscorlib.dll")); var compilation = CSharpCompilation.Create(testAsmName, syntaxTrees: new[] { tree }, references: new[] { mscorlib }); var emitResult = compilation.Emit($"{testAsmName}.dll"); if (!emitResult.Success) { throw new Exception(string.Join(Environment.NewLine, emitResult.Diagnostics.Select((x, i) => $"{i + 1}. {x}"))); } var ourAssembly = Assembly.Load(new AssemblyName(testAsmName)); var type = ourAssembly.GetType("MyClass"); var meth = type.GetRuntimeMethod("Main", Type.EmptyTypes); return () => meth.Invoke(null, null); } }
수정본
파일 열기
using System; using System.IO; using System.Linq; using System.Reflection; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; class Program { static void Main(string[] args) { var greetings = HelloWorlder.GetGreetings(); // should write Hello World greetings(); } } public static class HelloWorlder { public static Action GetGreetings() { var tree = CSharpSyntaxTree.ParseText(@" using System; public class MyClass { public static void Main() { //Console.WriteLine(""Hello World!""); //Console.ReadLine(); } }"); const string testAsmName = "testLib"; var coreDir = Path.GetDirectoryName(typeof(object).GetTypeInfo().Assembly.Location); var mscorlib = MetadataReference.CreateFromFile(Path.Combine(coreDir, "System.Private.CoreLib.dll")); var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); var compilation = CSharpCompilation.Create(testAsmName, syntaxTrees: new[] { tree }, references: new[] { mscorlib }, options: options); var ms = new MemoryStream(); var emitResult = compilation.Emit(ms); ms.Seek(0, SeekOrigin.Begin); if (!emitResult.Success) { throw new Exception(string.Join(Environment.NewLine, emitResult.Diagnostics.Select((x, i) => $"{i + 1}. {x}"))); } var ourAssembly = Assembly.Load(ms.ToArray()); var type = ourAssembly.GetType("MyClass"); var meth = type.GetRuntimeMethod("Main", Type.EmptyTypes); ms.Close(); return () => meth.Invoke(null, null); } }
비교하기