-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(finally) Improve formatting of InvocationExpressions #7
Comments
Printing InvocationExpressions well for all the variations looks like it will be a lot of work. See https://github.com/prettier/prettier/blob/main/src/language-js/print/member-chain.js for how complex it could get. |
I made some progress on formatting simpler cases than the ones above. Here is another one that needs some work this.Address1 = addressFields.Where(
field => field.FieldName == "Address1")
.Where(field => yeah)
.Where(field => yeah); |
More examples roleNames
.ToList()
.ForEach((role) =>
this.adminContextMock
.Setup((ctx) => ctx.IsUserInRole(role))
.Returns(false)
); |
This will require conditionalGroup, run it in prettier to see how they do it. var superLongMethodNameForceLine = someFactoryName
.SuperLongMethodNameForceLine()
.SomeOtherReallyLongMethodName(); |
Another edge case var linePosition________________________ = diagnostics[
i
].Location.GetLineSpan().StartLinePosition; |
this seems like extra indentation
|
Possibly already covered above with the
|
And
|
This is related, but I think it's actually an ImplicitObjectCreationExpression
|
Another edge case
|
Another example Diagnostic.Create(
_descriptor,
symbolForDiagnostic.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax()
.GetLocation()
?? Location.None,
symbol.ToDisplayString(SymbolDisplayFormat.CSharpShortErrorMessageFormat)
); |
Another example if (
endpoints[
i
].Metadata.GetMetadata<DynamicControllerRouteValueTransformerMetadata>() != null
) { |
This appears to have extra indentation because of the Invocation return value == null
? CallMethod(
value.ToString(),
"([a-z])([A-Z])",
"$1-$2",
RegexOptions.None,
TimeSpan.FromMilliseconds(100)
)
.ToLowerInvariant()
: Regex.Replace(
value.ToString(),
"([a-z])([A-Z])",
"$1-$2",
RegexOptions.None,
TimeSpan.FromMilliseconds(100)
)
.ToLowerInvariant(); |
FacebookGroupConnection<TStatus> statuses = await GetFacebookObjectAsync<
FacebookGroupConnection<TStatus>
>(client, "me/statuses");
// should maybe be
FacebookGroupConnection<TStatus> statuses =
await GetFacebookObjectAsync<FacebookGroupConnection<TStatus>>(
client,
"me/statuses"
); |
This used to be more lines, but more readable, maybe it should go back. var proxy1 =
generator.CreateInterfaceProxyWithTargetInterface<IEventHandler<EventArgs1>>(
null,
new[] { lazyInterceptor1 }
);
// is now
var proxy1 = generator.CreateInterfaceProxyWithTargetInterface<
IEventHandler<EventArgs1>
>(null, new[] { lazyInterceptor1 }); |
This may be related // used to be
var ex = Assert.Throws<ArgumentException>(
() =>
generator.CreateInterfaceProxyWithTargetInterface<IList<IList<PrivateInterface>>>(
new List<IList<PrivateInterface>>(),
new IInterceptor[0]
)
);
// is now
var ex = Assert.Throws<ArgumentException>(
() =>
generator.CreateInterfaceProxyWithTargetInterface<
IList<IList<PrivateInterface>>
>(new List<IList<PrivateInterface>>(), new IInterceptor[0])
); |
These are a bunch of edge cases that are probably related // these used to not break so weird
ref var parentFrame = ref diffContext.NewTree[
newFrame.ComponentReferenceCaptureParentFrameIndexField
];
var newComponentInstance = (CaptureSetParametersComponent)oldTree.GetFrames().Array[
0
].Component;
parent = (ContainerNode)parent.Children[
childIndexAtCurrentDepth + siblingIndex
];
configuration.EncryptionAlgorithmKeySize = (int)encryptionElement.Attribute(
"keyLength"
)!;
// used to break onto the next line
var cbTempSubkeys = checked(
_symmetricAlgorithmSubkeyLengthInBytes + _hmacAlgorithmSubkeyLengthInBytes
);
// but then this looks better with checked next to =
var cbEncryptedData = checked(
cbCiphertext
- (
KEY_MODIFIER_SIZE_IN_BYTES
+ _symmetricAlgorithmBlockSizeInBytes
+ _hmacAlgorithmDigestLengthInBytes
)
);
// used to be 2 lines
var cacheKey = (
ModelType: fieldIdentifier.Model.GetType(),
fieldIdentifier.FieldName
);
// this is better, but still looks weird
public AccessTokenNotAvailableException(
NavigationManager navigation,
AccessTokenResult tokenResult,
IEnumerable<string> scopes
) : base(
message: "Unable to provision an access token for the requested scopes: " + scopes
!= null
? $"'{string.Join(", ", scopes ?? Array.Empty<string>())}'"
: "(default scopes)"
) {
// this is just gross, it used to break parameters instead of generic types
var count = (int)await _invoker.InvokeUnmarshalled<
string[],
object?,
object?,
Task<object>
>(GetSatelliteAssemblies, culturesToLoad.ToArray(), null, null);
// not sure what to do with this
storedArguments[i] = localVariables[i] = Expression.Parameter(
parameters[i].ParameterType
); |
* Cleaning up the doc tree * Code review changes. Adding way to hide nulls on doc tree. Some minor performance tweaks * Formatting files * Moving away from SpaceBrace closes #423 * A little cleanup * Fixing extra indent in conditionals Closes #7 * Cleaning up the doc tree * Making some progress on chained invocations Fixing bug with ConditionalGroup * Switch back to printedNode * A little progress, possibly backwards * Possibly forwards this time * Testing notes * Merge predefinedTypes * Changing my mind again * Baby step forward * Another baby step * Fixing issues with ConditionalAccessExpression * Fix case where chain contains a hardline * Fixing comment edge case * Another edge case * more notes * Merge when identifier is short * Handling more edge cases * Some cleanup * Fixing edge case + some cleanup * Review changes + more efficient DocSerializer
Some examples
The text was updated successfully, but these errors were encountered: