forked from dotnet/maui
-
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.
* initialized cstyle casts * added integration and accessExpressionBuilder tests * added explicit cast to as cast adapter * Simplify inserting conditional access * Add integration tests --------- Co-authored-by: Simon Rozsival <[email protected]>
- Loading branch information
1 parent
d411076
commit a573668
Showing
8 changed files
with
551 additions
and
123 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
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
101 changes: 101 additions & 0 deletions
101
src/Controls/src/BindingSourceGen/GeneratorDataModels.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,101 @@ | ||
|
||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Microsoft.Maui.Controls.BindingSourceGen; | ||
|
||
public class TrackingNames | ||
{ | ||
public const string BindingsWithDiagnostics = nameof(BindingsWithDiagnostics); | ||
public const string Bindings = nameof(Bindings); | ||
} | ||
|
||
public sealed record BindingDiagnosticsWrapper( | ||
CodeWriterBinding? Binding, | ||
EquatableArray<DiagnosticInfo> Diagnostics); | ||
|
||
public sealed record CodeWriterBinding( | ||
InterceptorLocation Location, | ||
TypeDescription SourceType, | ||
TypeDescription PropertyType, | ||
EquatableArray<IPathPart> Path, | ||
SetterOptions SetterOptions); | ||
|
||
public sealed record SourceCodeLocation(string FilePath, TextSpan TextSpan, LinePositionSpan LineSpan) | ||
{ | ||
public static SourceCodeLocation? CreateFrom(Location location) | ||
=> location.SourceTree is null | ||
? null | ||
: new SourceCodeLocation(location.SourceTree.FilePath, location.SourceSpan, location.GetLineSpan().Span); | ||
|
||
public Location ToLocation() | ||
{ | ||
return Location.Create(FilePath, TextSpan, LineSpan); | ||
} | ||
|
||
public InterceptorLocation ToInterceptorLocation() | ||
{ | ||
return new InterceptorLocation(FilePath, LineSpan.Start.Line + 1, LineSpan.Start.Character + 1); | ||
} | ||
} | ||
|
||
public sealed record InterceptorLocation(string FilePath, int Line, int Column); | ||
|
||
public sealed record TypeDescription( | ||
string GlobalName, | ||
bool IsValueType = false, | ||
bool IsNullable = false, | ||
bool IsGenericParameter = false) | ||
{ | ||
public override string ToString() | ||
=> IsNullable | ||
? $"{GlobalName}?" | ||
: GlobalName; | ||
} | ||
|
||
public sealed record SetterOptions(bool IsWritable, bool AcceptsNullValue = false); | ||
|
||
public sealed record MemberAccess(string MemberName) : IPathPart | ||
{ | ||
public string? PropertyName => MemberName; | ||
|
||
public bool Equals(IPathPart other) | ||
{ | ||
return other is MemberAccess memberAccess && MemberName == memberAccess.MemberName; | ||
} | ||
} | ||
|
||
public sealed record IndexAccess(string DefaultMemberName, object Index) : IPathPart | ||
{ | ||
public string? PropertyName => $"{DefaultMemberName}[{Index}]"; | ||
|
||
public bool Equals(IPathPart other) | ||
{ | ||
return other is IndexAccess indexAccess && DefaultMemberName == indexAccess.DefaultMemberName && Index.Equals(indexAccess.Index); | ||
} | ||
} | ||
|
||
public sealed record ConditionalAccess(IPathPart Part) : IPathPart | ||
{ | ||
public string? PropertyName => Part.PropertyName; | ||
|
||
public bool Equals(IPathPart other) | ||
{ | ||
return other is ConditionalAccess conditionalAccess && Part.Equals(conditionalAccess.Part); | ||
} | ||
} | ||
|
||
public sealed record Cast(TypeDescription TargetType) : IPathPart | ||
{ | ||
public string? PropertyName => null; | ||
|
||
public bool Equals(IPathPart other) | ||
{ | ||
return other is Cast cast && TargetType.Equals(cast.TargetType); | ||
} | ||
} | ||
|
||
public interface IPathPart : IEquatable<IPathPart> | ||
{ | ||
public string? PropertyName { get; } | ||
} |
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
1 change: 0 additions & 1 deletion
1
src/Controls/tests/BindingSourceGen.UnitTests/AccessExpressionBuilderTests.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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System.Linq; | ||
using Microsoft.Maui.Controls.BindingSourceGen; | ||
using Xunit; | ||
|
||
|
Oops, something went wrong.