无法在AsyncPackage扩展中点击OnLoadOptions

问题描述

我想访问VS2019 .suo文件,我在线搜索,这是建议的方法

使您的包类实现import React,{ memo,useEffect,useState } from 'react'; import PropTypes from 'prop-types'; import { useComboBox } from 'downshift'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faChevronDown } from '@fortawesome/free-solid-svg-icons'; const comboBoxStyles = { display: 'inline-block',marginLeft: '5px' }; let Item = ({ isHighlighted,getItemProps,item,index }) => { return ( <li className="auto-complete-list-item" style={isHighlighted ? { backgroundColor: '#bde4ff' } : {}} key={`${item}${index}`} {...getItemProps({ item,index })} > {item} </li> ); }; Item = memo(Item); const Autocomplete = ({ items,onChange,isSubmitting }) => { const [inputItems,setInputItems] = useState(items); const { isOpen,getToggleButtonProps,getLabelProps,getMenuProps,getInputProps,getComboBoxProps,highlightedindex,inputValue,reset } = useComboBox({ items: inputItems,onSelectedItemChange: ({ inputValue }) => onChange(inputValue),onInputValueChange: ({ inputValue }) => { setInputItems( items.filter(item => item.toLowerCase().includes(inputValue.toLowerCase()) ) ); } }); useEffect(() => { if (inputValue.length > 0 && isSubmitting) reset(); },[inputValue,isSubmitting,reset]); return ( <div className="input-field"> <div style={comboBoxStyles} {...getComboBoxProps()}> <input name="autocomplete" {...getInputProps()} /> <button type="button" {...getToggleButtonProps()} aria-label="toggle menu" > <FontAwesomeIcon icon={faChevronDown} /> </button> </div> <ul {...getMenuProps()} className="auto-complete-list"> {isOpen && inputItems.map((item,index) => ( <Item key={item} isHighlighted={highlightedindex === index} getItemProps={getItemProps} item={item} index={index} /> ))} </ul> </div> ); }; Autocomplete.propTypes = { list: PropTypes.array }; export default Autocomplete;

IVsPersistSolutionopts

将以下代码添加到包的public sealed class MyExtensionPackage : AsyncPackage,IVsPersistSolutionopts 方法中:

InitializeAsync

添加var solutionPersistenceService = GetService(typeof(IVsSolutionPersistence)) as IVsSolutionPersistence; solutionPersistenceService.LoadPackageUserOpts(this,"MyOption"); solutionPersistenceService.LoadPackageUserOpts(this,"MyOption2"); 方法

OnLoadOptions

但是当我运行并加载扩展程序时,我无法进入protected override void OnLoadOptions(string key,Stream stream) { if (key.Equals("MyOption",StringComparison.InvariantCultureIgnoreCase)) { _myOption = new StreamReader(stream).ReadToEnd(); } else { base.OnLoadOptions(key,stream); } } ,还需要做些其他事情才能使其正常工作吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)