Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created March 6, 2019 12:41
Show Gist options
  • Save controlflow/69a677cf6aaa5e6a997afe43f34eb954 to your computer and use it in GitHub Desktop.
Save controlflow/69a677cf6aaa5e6a997afe43f34eb954 to your computer and use it in GitHub Desktop.
[Pure]
public static bool CanRemoveDesignation([NotNull] this IRecursivePattern recursivePattern)
{
if (recursivePattern.TypeUsage == null && recursivePattern.PropertyPatternClause == null)
{
var deconstructionPatternClause = recursivePattern.DeconstructionPatternClause;
if (deconstructionPatternClause != null)
{
if (deconstructionPatternClause.Patterns.Count == 1) return false;
}
}
return !recursivePattern.ContainsPreprocessorDirectiveChildren();
}
[Pure]
public static bool CanRemoveDesignation([NotNull] this IRecursivePattern recursivePattern)
{
if (recursivePattern is {
TypeUsage: null,
PropertyPatternClause: null,
DeconstructionPatternClause: { Patterns: { Count: 1 } }
})
{
return false;
}
return !recursivePattern.ContainsPreprocessorDirectiveChildren();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment