Skip to content

Instantly share code, notes, and snippets.

Mihhail Maslakov ionoy

Block or report user

Report or block ionoy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:2dd0f0b69317f65abf6b99246a5becf3
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()
View calculator.cs
using Clarity;
using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
namespace Sample.Calculator
{
using CalcOp = Func<double, double, double>;
View livexaml-container.cs
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 } ));
View Clarity-calculator.cs
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();
View a.cs
public class CodedUiTest : ContentView
{
public CodedUiTest ()
{
InitializeContentLive();
}
public void InitializeContentLive()
{
var grid = new Grid();
View LiveXamlHotReload.cs
// Attribute can be omitted if method name is exactly `InitializeContent`
[ContentInitializer]
public void InitializeContent() {
Content = new Grid {
...
};
}
View QuickInfoSourceProvider.cs
[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)
View nitra-mapping.nitra
Syntax:
extend syntax Expression
{
...
| Parenthesized = "(" Expression ")";
...
}
Mapping:
View binding.nitra
[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
}
View gist:d3a25be12823691fe0aedd28522edaef
[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;
You can’t perform that action at this time.