I have a VS extension project.
In the project I need to traverse thru all class and find all public properties with public getters.
the code looks like
private static IEnumerable<IntellisenseProperty> GetProperties(CodeElements props, HashSet<string> traversedTypes, HashSet<string> references = null)
{
return from p in props.OfType<CodeProperty>()
where !p.Attributes.Cast<CodeAttribute>().Any(a => "System.Runtime.Serialization.IgnoreDataMemberAttribute" == a.FullName || "Newtonsoft.Json.JsonIgnoreAttribute" == a.FullName)
where vsCMAccess.vsCMAccessPublic == p.Access && p.Getter != null && !p.Getter.IsShared && vsCMAccess.vsCMAccessPublic == p.Getter.Access
select new IntellisenseProperty
{
Name = GetName(p),
Type = GetType(p.Parent, p.Type, traversedTypes, references),
Summary = GetSummary(p),
JsonName = GetJsonName(p)
};
}
the following input cause the issue
sing System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Identity;
using Newtonsoft.Json;
using System.Runtime.Serialization;
namespace ClaimsManager.Models.UI
{
public class WindowsAccount
{
[JsonProperty("Test")]
public string UserName { get; set; }
[Required]
public string Domain { get; set; }
public string WindowsUserID => $"{Domain}\\{UserName}";
[JsonIgnore]
public UserLoginInfo UserLogin => new UserLoginInfo("Windows", WindowsUserID);
}
}
works great till it gets to
public string WindowsUserID => $"{Domain}\\{UserName}";
where it blows up on vsCMAccess.vsCMAccessPublic == p.Getter.Access with a COMException.
stack trace at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at Microsoft.VisualStudio.LanguageServices.Implementation.Utilities.Exceptions.ThrowEFail() at Microsoft.VisualStudio.LanguageServices.CSharp.CodeModel.CSharpCodeModelService.GetDefaultAccessibility(SyntaxNode node) at Microsoft.VisualStudio.LanguageServices.CSharp.CodeModel.CSharpCodeModelService.GetAccess(SyntaxNode node) at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements.CodeAccessorFunction.get_Access() at EnvDTE.CodeFunction.get_Access() at TypeScriptDefinitionGenerator.IntellisenseParser.IsPublic(CodeFunction cf) in C:\\code\\GitHub\\TypeScriptDefinitionGenerator\\src\\Generator\\IntellisenseParser.cs:line 190
HResult = 0x80004005
Message "Error HRESULT E_FAIL has been returned from a call to a COM component
Source "EnvDTE"
TargetSite {EnvDTE.vsCMAccess get_Access()}
the only properties this happens on are all expression-bodied members
Is the a EnvDTE issue?
If it is an EnvDTE issue....how / where do I report it.
好吧,我放了一个错误并修复了Roslyn ....它计划在15.3版中发布
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.