Skip to content

Instantly share code, notes, and snippets.

View ionoy's full-sized avatar

Mihhail Maslakov ionoy

  • Estonia
View GitHub Profile
Install LiveSharp extension: https://marketplace.visualstudio.com/items?itemName=ionoy.LiveSharp
Install LiveSharp NuGet package: https://www.nuget.org/packages/livesharp
1) add [assembly:LiveSharpInjectRuleBaseClass("Xamarin.Forms.ContentPage", "Xamarin.Forms.ContentView")] attribute to App.xaml.cs
2) add [LiveSharpStart] attribute to App constructor
3) add this code to the end of App constructor
LiveSharpContext.AddUpdateHandler(ctx => {
var instances = ctx.UpdatedMethods
.SelectMany(method => method.Instances)
.Distinct()
using Clarity;
using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
namespace Sample.Calculator
{
using CalcOp = Func<double, double, double>;
class MyView : View, IElementController
{
public static BindableProperty HostedPageProperty = BindableProperty.Create("HostedPage", typeof(Page), typeof(MyView), propertyChanged: OnHostedPageChanged);
ReadOnlyCollection<Element> _logicalChildrenInner = new ReadOnlyCollection<Element>(new List<Element>());
ReadOnlyCollection<Element> IElementController.LogicalChildren => _logicalChildrenInner;
public void SetHostedPage(Page page)
{
_logicalChildrenInner = new ReadOnlyCollection<Element>(new List<Element>(new[] { page } ));
using Clarity;
using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
namespace Sample.Calculator
{
public class App : Application {
public App() => MainPage = new Calculator().MainPage();
public class CodedUiTest : ContentView
{
public CodedUiTest ()
{
InitializeContentLive();
}
public void InitializeContentLive()
{
var grid = new Grid();
// Attribute can be omitted if method name is exactly `InitializeContent`
[ContentInitializer]
public void InitializeContent() {
Content = new Grid {
...
};
}
[Export(typeof(IQuickInfoSourceProvider))]
[Name("Mouse processor")]
[ContentType(Strings.AmmyContentType)]
[TextViewRole(PredefinedTextViewRoles.Interactive)]
internal sealed class QuickInfoSourceProvider : IQuickInfoSourceProvider
{
[Import]
SVsServiceProvider serviceProvider;
public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer)
Syntax:
extend syntax Expression
{
...
| Parenthesized = "(" Expression ")";
...
}
Mapping:
[ExplicitSpaces]
syntax Binding = "bind" s Path=BindingPath? Source=("from" s BindingSource)? Converter=("convert" s LambdaExpr s)? ConverterBack=("convertback" s LambdaExpr s)? Settings=("set" s "[" s (!"set" NodeMember; ContentDelimiter)* s "]")?;
syntax BindingPath
{
| StringLiteral
| Parameter = "$" Key=Reference
| QRef = Key=QualifiedReference
}
[CompileStatistic("RegularRuleParser")]
public static int _#_NotEscs_(int pos, string text)
{
int okPos = -1;
if (pos < text.Length)
{
int curPos = pos + 1;
while (true)
{
okPos = curPos;