protected static int GetTelemetryPrefix(CodeAction codeAction) { // AssemblyQualifiedName will change across version numbers, FullName won't var type = codeAction.GetType(); type = type.IsConstructedGenericType ? type.GetGenericTypeDefinition() : type; return(type.FullName.GetHashCode()); }
public override bool TryGetTelemetryId(out Guid telemetryId) { // We get the telemetry id for the original code action we are fixing, // not the special 'FixAllCodeAction'. that is the .CodeAction this // SuggestedAction is pointing at. telemetryId = _originalCodeAction.GetType().GetTelemetryId(_fixAllState.Scope.GetScopeIdForTelemetry()); return(true); }
public static ImmutableArray <CodeAction>?TryGetNestedAction(CodeAction group) { if (group.GetType() is { Name : "CodeActionWithNestedActions" } groupType) { var nestedCodeActionObj = groupType.GetProperty("NestedCodeActions", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)?.GetValue(group); if (nestedCodeActionObj != null) { return((ImmutableArray <CodeAction>)nestedCodeActionObj); } } return(null); }
public bool TryGetTelemetryId(out Guid telemetryId) { // TODO: this is temporary. Diagnostic team needs to figure out how to provide unique id per a fix. // for now, we will use type of CodeAction, but there are some predefined code actions that are used by multiple fixes // and this will not distinguish those // AssemblyQualifiedName will change across version numbers, FullName won't var type = CodeAction.GetType(); type = type.IsConstructedGenericType ? type.GetGenericTypeDefinition() : type; telemetryId = new Guid(type.FullName.GetHashCode(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); return(true); }
private static void VerifyCodeAction([NotNull] CodeAction codeAction, [NotNull] Document document, [NotNull] string expectedCode) { Guard.NotNull(codeAction, nameof(codeAction)); if (codeAction.GetType().Name != "SolutionChangeAction") { Guard.NotNull(expectedCode, nameof(expectedCode)); ImmutableArray <CodeActionOperation> operations = codeAction.GetOperationsAsync(CancellationToken.None).Result; operations.Should().HaveCount(1); VerifyOperationText(operations.Single(), expectedCode, document); } }
public virtual bool TryGetTelemetryId(out Guid telemetryId) { telemetryId = CodeAction.GetType().GetTelemetryId(); return(true); }