public override void Build(IEventSymbol symbol, RoslynCodeBuilder roslynCodeBuilder) { base.Build(symbol, roslynCodeBuilder); roslynCodeBuilder.AddEmptyLine(); roslynCodeBuilder.AddLine("protected void OnPropertyChanged(string propName)"); roslynCodeBuilder.Push(); roslynCodeBuilder.AddLine($"this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName))", true); roslynCodeBuilder.Pop(); }
protected override void BuildImpl(IMethodSymbol methodWrapperSymbol, RoslynCodeBuilder roslynCodeBuilder) { bool shouldOverride = (!ForceNoOverride) && methodWrapperSymbol.ShouldOverride(); roslynCodeBuilder.AddMethodOpeningFromSymbolOnly(methodWrapperSymbol, shouldOverride); string returnVarName = "result"; string firstLineInsert = ""; if (!methodWrapperSymbol.ReturnsVoid) { string returnTypeStr = (methodWrapperSymbol.ReturnType as INamedTypeSymbol).GetFullTypeString(); roslynCodeBuilder.AddLine($"{returnTypeStr} {returnVarName} = default({returnTypeStr})", true); firstLineInsert = $"{returnVarName} = "; } if (this.IncludeBaseVirtualInOverride) { roslynCodeBuilder.AddEmptyLine(); roslynCodeBuilder.AddMethodCall(WrapperSymbol, $"base.{WrapperSymbolName}"); } bool isFirst = true; foreach (MemberMapInfo memberMap in this.WrappedMembers) { memberMap.AddCheckForSharedLine(roslynCodeBuilder); roslynCodeBuilder.Push(); roslynCodeBuilder.AddLine(); if (isFirst) { roslynCodeBuilder.AddText(firstLineInsert); isFirst = false; } memberMap.AddPluginMethodLine(this.WrapperSymbol, roslynCodeBuilder); roslynCodeBuilder.Pop(); } if (!methodWrapperSymbol.ReturnsVoid) { roslynCodeBuilder.AddReturnVar(returnVarName); } roslynCodeBuilder.Pop(true); }
protected override void BuildImpl(IMethodSymbol methodWrapperSymbol, RoslynCodeBuilder roslynCodeBuilder) { roslynCodeBuilder.AddMethodOpeningFromSymbolOnly(methodWrapperSymbol); string returnVarName = "result"; string firstLineInsert = ""; if (!methodWrapperSymbol.ReturnsVoid) { firstLineInsert = (methodWrapperSymbol.ReturnType as INamedTypeSymbol).GetFullTypeString() + $" {returnVarName} = "; } if (this.IncludeBaseVirtualInOverride) { roslynCodeBuilder.AddEmptyLine(); roslynCodeBuilder.AddMethodCall(WrapperSymbol, $"base.{WrapperSymbolName}"); } bool isFirst = true; foreach (MemberMapInfo memberMap in this.WrappedMembers) { roslynCodeBuilder.AddEmptyLine(); if (isFirst) { roslynCodeBuilder.AddText(firstLineInsert); isFirst = false; } IMethodSymbol wrappedMethodSymbol = memberMap.TheWrappedSymbol as IMethodSymbol; if (memberMap.IsNonPublic) { if (memberMap.AllowNonPublic) { roslynCodeBuilder .AddNonPublicMethodCall ( WrapperSymbol, memberMap.WrappedObjPropName, memberMap.WrappedMemberName, wrappedMethodSymbol ); } } else { if (memberMap.TheWrappedSymbol.IsStatic) { roslynCodeBuilder.AddStaticMethodCall ( WrapperSymbol, memberMap.WrappedObjPropName, memberMap.WrappedClassMemberFullName); } else { roslynCodeBuilder.AddMethodCall ( WrapperSymbol, memberMap.WrappedClassMemberFullName); } } } if (!methodWrapperSymbol.ReturnsVoid) { roslynCodeBuilder.AddReturnVar(returnVarName); } roslynCodeBuilder.Pop(true); }