public FmtToken Format() { return(FmtToken.Concat(ImmutableArray.Create((object)"a {h = ", (object)FmtToken.FormatArray(H), (object)"}"), new string[3] { "", "h", "" })); }
public FmtToken Format() { return(FmtToken.Concat(ImmutableArray.Create(new object[5] { "Test123 {Field543 = ", FmtToken.FormatArray(Field543), ", abcSS = ", AbcSS, "}" }), new string[5] { "", "Field543", "", "abcSS", "" })); }
public FmtToken Format() { return(FmtToken.Concat(ImmutableArray.Create(new object[5] { "T {a = ", A, ", b = ", FmtToken.FormatArray(B), "}" }), new string[5] { "", "a", "", "b", "" })); }
public FmtToken Format() { return(FmtToken.Concat(ImmutableArray.Create(new object[15] { "Composite123 {StringF = ", StringF, ", NullableStringF = ", NullableStringF, ", NullableIntF = ", NullableIntF, ", IntF = ", IntF, ", FloatF = ", FloatF, ", NullListF = ", FmtToken.FormatArray(NullListF), ", ThisF = ", ThisF, "}" }), new string[15] { "", "StringF", "", "NullableStringF", "", "NullableIntF", "", "IntF", "", "FloatF", "", "NullListF", "", "ThisF", "" })); }
public FmtToken Format() => this.TypeArguments.IsEmpty ? FmtToken.Single(this.Type, "type") : FmtToken.Concat(this.Type, FmtToken.FormatArray(this.TypeArguments, "<", ">")) .WithTokenNames("type", "genericParameters");
static partial void ValidateObjectExtension(ref ValidationErrorsBuilder e, MethodDef obj) { if (obj.Implements.IsDefault) { e.AddErr("default(ImmutableArray<...>) is not allowed value", "implements"); } var sgn = obj.Signature; if (obj.Body is object && obj.Body.Type() != sgn.ResultType) { e.Add(ValidationErrors.Create($"Method body was expected to return {sgn.ResultType}, not {obj.Body.Type()}").Nest("body")); // TODO: expression type validation } var isWithoutBody = obj.Signature.IsAbstract || obj.Signature.DeclaringType.Kind == "interface"; if (obj.Body is null && !isWithoutBody) { e.Add(ValidationErrors.Create($"Method is not abstract, so it must contain a body.")); } if (obj.Body is object && isWithoutBody) { e.Add(ValidationErrors.Create($"Method is abstract, so it must not contain a body. Did you intent to use MethodDef.InterfaceDef?")); } if (!isWithoutBody) { if (obj.ArgumentParams.IsDefault) { e.AddErr("default(ImmutableArray<...>) is not allowed value", "argumentParams"); } var expectedArgs = obj.Signature.Params.Select(p => p.Type).ToImmutableArray(); if (!sgn.IsStatic) { expectedArgs = expectedArgs.Insert(0, sgn.DeclaringType.SpecializeByItself()); } if (obj.ArgumentParams.Length != expectedArgs.Length) { e.Add(ValidationErrors.Create($"Expected {expectedArgs.Length} arguments, got {obj.ArgumentParams.Length}: {FmtToken.FormatArray(obj.ArgumentParams)}").Nest("length").Nest("argumentParams")); } for (int i = 0; i < Math.Min(obj.ArgumentParams.Length, expectedArgs.Length); i++) { if (obj.ArgumentParams[i].Type.UnwrapReference() != expectedArgs[i].UnwrapReference()) { e.Add(ValidationErrors.Create($"Argument type {expectedArgs[i]} was expected instead of {obj.ArgumentParams[i].Type}.") .Nest("type").Nest(i.ToString()).Nest("argumentParams") ); } } if (!sgn.IsStatic) { var firstArgument = obj.ArgumentParams.First(); if (sgn.DeclaringType.IsValueType) { if (TypeReference.ByReferenceType(sgn.DeclaringType.SpecializeByItself()) != firstArgument.Type) { e.AddErr($"Method on value type should have this of a reference type: {firstArgument.Type}&", "argumentParams", "0", "type"); } } } } // TODO: deep validate expression in the context }