protected override void CommandAction(DTEHelper helper) { EnvDTE.Document document = helper.GetOpenedDocumentInCodeWindow(FileOperations.SupportsXmlType); if (document != null) { var objTextDoc = document.Object(nameof(EnvDTE.TextDocument)); if (objTextDoc != null && objTextDoc is EnvDTE.TextDocument textDocument ) { string fetchXml = textDocument.StartPoint.CreateEditPoint().GetText(textDocument.EndPoint); string codeCSharp = ContentComparerHelper.ConvertFetchXmlToQueryExpression(fetchXml); ClipboardHelper.SetText(codeCSharp); } } }