public static MethodSignature ReadSignature(ImperativeCodeModel codeModel, IMethodSymbol symbol) { var parameters = symbol.Parameters.Select((p, index) => new MethodParameter { Name = p.Name, Position = index + 1, Type = codeModel.TryGet <TypeMember>(p.Type), Modifier = p.GetParameterModifier(), }); var hasReturnType = ( symbol.MethodKind != MethodKind.Constructor && symbol.MethodKind != MethodKind.StaticConstructor && !symbol.ReturnsVoid); var returnValue = ( hasReturnType ? new MethodParameter { Name = "$retVal", Position = 0, Type = codeModel.TryGet <TypeMember>(symbol.ReturnType), Modifier = symbol.GetReturnValueModifier(), } : null ); return(new MethodSignature { IsAsync = symbol.IsAsync, ReturnValue = returnValue, Parameters = parameters.ToList() }); }
public static TypeMember TryGetMemberFromTypeof(this ImperativeCodeModel codeModel, AbstractExpression expression) { return( (expression as ConstantExpression)?.Value is INamedTypeSymbol typeSymbol ? codeModel.TryGet <TypeMember>(binding: typeSymbol) : null); }
public ClrTypeReader(Type clrType, TypeMember typeMember, ImperativeCodeModel codeModel, int distance) { _clrType = clrType; _typeMember = typeMember; _codeModel = codeModel; _distance = distance; }
public void Complete(TypeMember existingType, ImperativeCodeModel codeModel) { var clrType = existingType.Bindings.First <System.Type>(); var reader = new ClrTypeReader(clrType, existingType, codeModel, distance: 0); reader.ReadAll(); }
public WebUIMetadata(ImperativeCodeModel imperativeCodeModel) { _imperativeCodeModel = imperativeCodeModel; this.Pages = DiscoverWebPages(); // calls to GetApiMetadata made during web page discovery, populate _backendApiByType this.BackendApis = _backendApiByType.Values.ToImmutableArray(); }
public HyperappAdapter(ImperativeCodeModel codeModel, IComponentAdapterFactory componentAdapterFactory, ICodeGeneratorOutput output) { _codeModel = codeModel; _componentAdapterFactory = componentAdapterFactory; _output = output; _codeWriter = new JavaScriptCodeWriter(output); }
public WebApiMetadata(ImperativeCodeModel imperativeCodeModel, TypeMember interfaceType) { _imperativeCodeModel = imperativeCodeModel; this.InterfaceType = interfaceType; this.ServiceName = interfaceType.Name.TrimPrefixFragment("I").TrimSuffixFragment("Service"); this.ApiMethods = DiscoverApiMethods(); }
public WebPageMetadata(ImperativeCodeModel imperativeCodeModel, IBackendApiRegistry apiRegistry, TypeMember pageClass) { _imperativeCodeModel = imperativeCodeModel; _apiRegistry = apiRegistry; this.PageClass = pageClass; this.StateClass = pageClass.BaseType.GenericArguments[0]; this.ControllerMethod = TryFindControllerMethod(); this.ModelProperty = FindModelProperty(); this.Components = DiscoverComponents(); this.BackendApis = DiscoverBackendApis(); this.IsIndex = pageClass.HasAttribute <WebUI.Semantic.IndexPageAttribute>(); }
public static TypeMember ResolveType(Type clrType, ImperativeCodeModel codeModel, int distance) { var typeMember = new TypeMember(); var reader = new ClrTypeReader(clrType, typeMember, codeModel, distance); codeModel.Add(typeMember, isTopLevel: !clrType.IsNested); if (distance > 0) { reader.ReadNameOnly(); } else { reader.ReadAll(); } return(typeMember); }
public WebComponentMetadata( WebPageMetadata page, ImperativeCodeModel imperativeCodeModel, PropertyMember declaredProperty, MethodMember controllerMethod) { _imperativeCodeModel = imperativeCodeModel; this.Page = page; this.DeclaredProperty = declaredProperty; this.ComponentClass = declaredProperty.PropertyType; this.ModelClass = ComponentClass.GenericArguments.FirstOrDefault(); this.PropertyMap = new Dictionary <IdentifierName, AbstractExpression>(); this.EventMap = new EventMapMetadata(); this.ModelMetadata = new ModelObjectMetadata(ModelClass); //TODO: add AbstractMember.HasAttribute<T>()/TryGetAttribute<T>() this.IsPredefined = ( ComponentClass.Bindings.FirstOrDefault <Type>()?.GetCustomAttribute <ProgrammingModelAttribute>() != null); ParsePropertyValues(); FindEventHandlers(controllerMethod); }
public UnitSyntaxEmitter(ImperativeCodeModel codeModel, TypeMember type) { _codeModel = codeModel; _type = type; }
TypeMember IClrTypeResolver.Resolve(Type clrType, ImperativeCodeModel codeModel, int distance) { return(ResolveType(clrType, codeModel, distance)); }
public static TypeMember GetMemberFromTypeof(this ImperativeCodeModel codeModel, AbstractExpression expression) { return( TryGetMemberFromTypeof(codeModel, expression) ?? throw new Exception($"could not find TypeMember referred by typeof")); }
public AspNetAdapter(ImperativeCodeModel codeModel, ICodeGeneratorOutput output) { _codeModel = codeModel; _output = output; }
public RoslynCodeModelWriter(ImperativeCodeModel codeModel, ICodeGeneratorOutput output) { _codeModel = codeModel; _output = output; }