-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef21741
commit 559952a
Showing
9 changed files
with
193 additions
and
118 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
8 changes: 8 additions & 0 deletions
8
...arks/Generated/MapperGenerator/MapperGenerator.MapperGenerator/CreateMapperAttribute.g.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,8 @@ | ||
| ||
namespace DotNetThoughts.FartingUnicorn | ||
{ | ||
[System.AttributeUsage(System.AttributeTargets.Class)] | ||
public class CreateMapperAttribute : System.Attribute | ||
{ | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...nerator/MapperGenerator.MapperGenerator/Mapper.FartingUnicorn.Benchmarks.UserProfile.g.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,12 @@ | ||
using DotNetThoughts.Results; | ||
using System.Text.Json; | ||
|
||
namespace FartingUnicorn.Generated; | ||
public static partial class Mappers | ||
{ | ||
public static Result<FartingUnicorn.Benchmarks.UserProfile> MapToUserProfile(JsonElement jsonElement) | ||
{ | ||
var result = new FartingUnicorn.Benchmarks.UserProfile(); | ||
return Result<FartingUnicorn.Benchmarks.UserProfile>.Ok(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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
using System.Text; | ||
|
||
namespace MapperGenerator; | ||
|
||
public class SourceBuilder | ||
{ | ||
private int _indentLevel; | ||
private readonly int _indentSize; | ||
private readonly List<string> _indentStrings; | ||
private readonly StringBuilder _stringBuilder; | ||
|
||
public SourceBuilder() | ||
{ | ||
_indentLevel = 0; | ||
_indentSize = 4; | ||
_indentStrings = new List<string> { "" }; | ||
_stringBuilder = new StringBuilder(); | ||
} | ||
public void AppendLine(string line) | ||
{ | ||
if (_stringBuilder != null) | ||
{ | ||
_stringBuilder | ||
.Append(_indentStrings[_indentLevel]) | ||
.AppendLine(line); | ||
} | ||
} | ||
|
||
public IDisposable Indent() | ||
{ | ||
_indentLevel++; | ||
if (_indentLevel == _indentStrings.Count) | ||
{ | ||
_indentStrings.Add(new string(' ', _indentSize * _indentLevel)); | ||
} | ||
return new Unindent(() => _indentLevel--); | ||
} | ||
|
||
public override string? ToString() | ||
{ | ||
return _stringBuilder.ToString(); | ||
} | ||
|
||
public SourceText ToSourceText() | ||
{ | ||
return SourceText.From(_stringBuilder.ToString(), Encoding.UTF8); | ||
} | ||
|
||
internal void AppendLine() | ||
{ | ||
_stringBuilder.AppendLine(); | ||
} | ||
|
||
private class Unindent : IDisposable | ||
{ | ||
private Func<int> _unindent; | ||
|
||
public Unindent(Func<int> unindent) | ||
{ | ||
_unindent = unindent; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_unindent(); | ||
} | ||
} | ||
} |
Oops, something went wrong.