-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support writing records with skipped fields in generated code
- Loading branch information
1 parent
31ceccf
commit aa03d61
Showing
28 changed files
with
438 additions
and
512 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<Project> | ||
<ItemGroup> | ||
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-3.final" /> | ||
<PackageVersion Include="MSTest" Version="3.6.3" /> | ||
</ItemGroup> | ||
</Project> |
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
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
75 changes: 0 additions & 75 deletions
75
src/Addax.Formats.Tabular.Analyzers.CSharp/SourceTextBuilder.cs
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
src/Addax.Formats.Tabular.Analyzers.CSharp/SourceTextWriter.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// (c) Oleksandr Kozlenko. Licensed under the MIT license. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Text; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Addax.Formats.Tabular.Analyzers.CSharp | ||
{ | ||
internal sealed class SourceTextWriter : IDisposable | ||
{ | ||
private readonly MemoryStream _memoryStream = new MemoryStream(); | ||
private readonly StreamWriter _streamWriter; | ||
private readonly char _indentChar; | ||
private readonly int _indentSize; | ||
|
||
public SourceTextWriter(Encoding encoding, char indentChar, int indentSize) | ||
{ | ||
Debug.Assert(encoding != null); | ||
Debug.Assert(indentSize >= 0); | ||
|
||
_streamWriter = new StreamWriter(_memoryStream, encoding); | ||
_indentChar = indentChar; | ||
_indentSize = indentSize; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_streamWriter.Dispose(); | ||
} | ||
|
||
public void WriteLine(string value) | ||
{ | ||
Debug.Assert(value != null); | ||
|
||
var indentation = Indent * _indentSize; | ||
|
||
for (var i = 0; i < indentation; i++) | ||
{ | ||
_streamWriter.Write(_indentChar); | ||
} | ||
|
||
_streamWriter.WriteLine(value); | ||
} | ||
|
||
public void WriteLine() | ||
{ | ||
_streamWriter.WriteLine(); | ||
} | ||
|
||
public SourceText ToSourceText() | ||
{ | ||
_streamWriter.Flush(); | ||
|
||
return SourceText.From(_memoryStream, _streamWriter.Encoding, canBeEmbedded: true); | ||
} | ||
|
||
public void Reset() | ||
{ | ||
Indent = 0; | ||
|
||
_memoryStream.SetLength(0); | ||
} | ||
|
||
public int Indent | ||
{ | ||
get; | ||
set; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.