public static void CopyFile(string from, string into)
{
using (var fromFile = File.Open(from, FileMode.Open, FileAccess.Read))
using (var toFile = File.Open(into, FileMode.Create, FileAccess.Write))
{
// ... Perform actual file copy
// Both FileStream objects are disposed at the end of the enclosing scope,
// in this case, the method declaration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.MSBuild; | |
namespace ConsoleApplication11 | |
{ | |
class Program | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.CSharp; | |
using Microsoft.CodeAnalysis.Text; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var list = new List<int>(); | |
list.Where(x => x % 2 == 0).OrderByDescending(x => x) | |
.Select(x => x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var list = new List<int>(); | |
list.Where(x => x % 2 == 0) | |
.OrderByDescending(x => x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compilation = project.GetCompilationAsync().Result; | |
var specificDiagnosticOptions = new[] { new KeyValuePair<string, ReportDiagnostic>(NotReportedByDefaultAnalyzer.DiagnosticId, ReportDiagnostic.Warn) }; | |
var options = new CSharpCompilationOptions(outputKind: OutputKind.DynamicallyLinkedLibrary, specificDiagnosticOptions: specificDiagnosticOptions); | |
var compilationWithOptions = compilation.WithOptions(options); | |
var compilationWithAnalyzers = compilationWithOptions.WithAnalyzers(ImmutableArray.Create(analyzer)); | |
var diags = compilationWithAnalyzers.GetAnalyzerDiagnosticsAsync().Result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Collections.Immutable; | |
using Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.CSharp; | |
using Microsoft.CodeAnalysis.CSharp.Syntax; | |
using Microsoft.CodeAnalysis.Diagnostics; | |
using static Microsoft.CodeAnalysis.Diagnostic; | |
namespace Analyzer1 { | |
[DiagnosticAnalyzer(LanguageNames.CSharp)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.CSharp; | |
namespace GetTypeName | |
{ | |
class Program | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = "\n"; // token.ValueText.Contains("\n") == true | |
var b = @"\n"; // token.ValueText.Contains("\n") == false | |
var c = @" | |
"; // token.ValueText.Contains("\n") == true | |
var d = $@"\n";// token.ValueText.Contains("\n") == false | |
var e = $@" | |
"; // token.ValueText.Contains("\n") == false |
public static void CopyFile(string from, string into)
{
using (var fromFile = File.Open(from, FileMode.Open, FileAccess.Read))
using (var toFile = File.Open(into, FileMode.Create, FileAccess.Write))
{
// ... Perform actual file copy
// Both FileStream objects are disposed at the end of the enclosing scope,
// in this case, the method declaration.
OlderNewer