本文整理汇总了C#中WellKnownMember类的典型用法代码示例。如果您正苦于以下问题:C# WellKnownMember类的具体用法?C# WellKnownMember怎么用?C# WellKnownMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WellKnownMember类属于命名空间,在下文中一共展示了WellKnownMember类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReportErrorOnWellKnownMember
private static void ReportErrorOnWellKnownMember(Symbol symbol, WellKnownMember member, DiagnosticBag diagnostics, ref bool hasError)
{
if ((object)symbol == null)
{
MemberDescriptor memberDescriptor = WellKnownMembers.GetDescriptor(member);
diagnostics.Add(ErrorCode.ERR_MissingPredefinedMember, NoLocation.Singleton,
((WellKnownType)memberDescriptor.DeclaringTypeId).GetMetadataName(), memberDescriptor.Name);
hasError = true;
}
else
{
ReportErrorOnSymbol(symbol, diagnostics, ref hasError);
ReportErrorOnSymbol(symbol.ContainingType, diagnostics, ref hasError);
}
}
示例2: WellKnownMethod
public MethodSymbol WellKnownMethod(WellKnownMember wm, bool isOptional = false)
{
return (MethodSymbol)WellKnownMember(wm, isOptional);
}
示例3: WellKnownMember
/// <summary>
/// Get the symbol for a well-known member. The use of this method to get a well-known member
/// that does not exist will result in an exception of type MissingPredefinedMember being thrown
/// containing an appropriate diagnostic for the caller to report.
/// </summary>
/// <param name="wm">The desired well-known member</param>
/// <param name="isOptional">If true, the method may return null for a missing member without an exception</param>
/// <returns>A symbol for the well-known member, or null if it is missing and isOptions == true</returns>
public Symbol WellKnownMember(WellKnownMember wm, bool isOptional = false)
{
Symbol wellKnownMember = Binder.GetWellKnownTypeMember(Compilation, wm, Diagnostics, syntax: Syntax, isOptional: true);
if (wellKnownMember == null && !isOptional)
{
RuntimeMembers.MemberDescriptor memberDescriptor = WellKnownMembers.GetDescriptor(wm);
WellKnownType containingType = (WellKnownType)memberDescriptor.DeclaringTypeId;
var diagnostic = new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, containingType.GetMetadataName(), memberDescriptor.Name), Syntax.Location);
throw new MissingPredefinedMember(diagnostic);
}
return wellKnownMember;
}
示例4: Property
public BoundExpression Property(BoundExpression receiver, WellKnownMember member)
{
var propertySym = WellKnownMember(member) as PropertySymbol;
Debug.Assert(!propertySym.IsStatic);
Debug.Assert(receiver.Type.GetMembers(propertySym.Name).OfType<PropertySymbol>().Single() == propertySym);
//if (propertySym == null) return BoundBadExpression
Binder.ReportUseSiteDiagnostics(propertySym, Diagnostics, Syntax);
Debug.Assert(!propertySym.IsStatic);
return Call(receiver, propertySym.GetMethod);
}
示例5: TryCreate
private static bool TryCreate(
SyntheticBoundNodeFactory F,
NamedTypeSymbol builderType,
TypeSymbol resultType,
WellKnownMember setException,
WellKnownMember setResult,
WellKnownMember awaitOnCompleted,
WellKnownMember awaitUnsafeOnCompleted,
WellKnownMember start,
WellKnownMember setStateMachine,
PropertySymbol task,
out AsyncMethodBuilderMemberCollection collection)
{
MethodSymbol setExceptionMethod;
MethodSymbol setResultMethod;
MethodSymbol awaitOnCompletedMethod;
MethodSymbol awaitUnsafeOnCompletedMethod;
MethodSymbol startMethod;
MethodSymbol setStateMachineMethod;
if (TryGetWellKnownMethodAsMember(F, setException, builderType, out setExceptionMethod) &&
TryGetWellKnownMethodAsMember(F, setResult, builderType, out setResultMethod) &&
TryGetWellKnownMethodAsMember(F, awaitOnCompleted, builderType, out awaitOnCompletedMethod) &&
TryGetWellKnownMethodAsMember(F, awaitUnsafeOnCompleted, builderType, out awaitUnsafeOnCompletedMethod) &&
TryGetWellKnownMethodAsMember(F, start, builderType, out startMethod) &&
TryGetWellKnownMethodAsMember(F, setStateMachine, builderType, out setStateMachineMethod))
{
collection = new AsyncMethodBuilderMemberCollection(
builderType,
resultType,
setExceptionMethod,
setResultMethod,
awaitOnCompletedMethod,
awaitUnsafeOnCompletedMethod,
startMethod,
setStateMachineMethod,
task);
return true;
}
collection = default(AsyncMethodBuilderMemberCollection);
return false;
}
示例6: MakeMemberMissing
internal void MakeMemberMissing(WellKnownMember member)
{
MakeMemberMissing((int)member);
}
示例7: EnsureWellKnownMember
private Symbol EnsureWellKnownMember(WellKnownMember member, DiagnosticBag bag)
{
return Binder.GetWellKnownTypeMember(F.Compilation, member, bag, body.Syntax.Location);
}
示例8: StaticCall
public BoundExpression StaticCall(WellKnownMember method, params BoundExpression[] args)
{
MethodSymbol methodSymbol = WellKnownMethod(method);
Binder.ReportUseSiteDiagnostics(methodSymbol, Diagnostics, Syntax);
Debug.Assert(methodSymbol.IsStatic);
return Call(null, methodSymbol, args);
}
示例9: MethodInfo
public BoundExpression MethodInfo(WellKnownMember meth)
{
var method = (MethodSymbol)WellKnownMember(meth);
return MethodInfo(method);
}
示例10: OpenMethodImplementation
public SynthesizedImplementationMethod OpenMethodImplementation(WellKnownMember interfaceMethod, string methodName = null, bool debuggerHidden = false, MethodSymbol asyncKickoffMethod = null)
{
var methodToImplement = (MethodSymbol)this.WellKnownMember(interfaceMethod);
return OpenMethodImplementation(methodToImplement, methodName, debuggerHidden, asyncKickoffMethod: asyncKickoffMethod);
}
示例11: TryGetWellKnownPropertyAsMember
private static bool TryGetWellKnownPropertyAsMember(SyntheticBoundNodeFactory F, WellKnownMember wellKnownProperty, NamedTypeSymbol containingType, out PropertySymbol propertySymbol)
{
propertySymbol = F.WellKnownMember(wellKnownProperty) as PropertySymbol;
if ((object)propertySymbol == null) return false;
propertySymbol = propertySymbol.AsMember(containingType);
return true;
}
示例12: TryGetWellKnownMethodAsMember
private static bool TryGetWellKnownMethodAsMember(SyntheticBoundNodeFactory F, WellKnownMember wellKnownMethod, NamedTypeSymbol containingType, out MethodSymbol methodSymbol)
{
methodSymbol = F.WellKnownMember(wellKnownMethod) as MethodSymbol;
if ((object)methodSymbol == null) return false;
methodSymbol = methodSymbol.AsMember(containingType);
return true;
}
示例13: MethodInfo
public BoundExpression MethodInfo(WellKnownMember method)
{
return MethodInfo(WellKnownMethod(method));
}
示例14: MakeBinderConstruction
private BoundExpression MakeBinderConstruction(WellKnownMember factoryMethod, BoundExpression[] args)
{
var binderFactory = _factory.WellKnownMember(factoryMethod);
if ((object)binderFactory == null)
{
return null;
}
return _factory.Call(null, (MethodSymbol)binderFactory, args.AsImmutableOrNull());
}
示例15: ReportUseSiteDiagnosticForSynthesizedAttribute
/// <summary>
/// Report diagnostics that should be reported when using a synthesized attribute.
/// </summary>
internal static void ReportUseSiteDiagnosticForSynthesizedAttribute(
CSharpCompilation compilation,
WellKnownMember attributeMember,
DiagnosticBag diagnostics,
Location location = null,
CSharpSyntaxNode syntax = null)
{
Debug.Assert((location != null) ^ (syntax != null));
// Dev11 reports use-site diagnostics when an optional attribute is found but is bad for some other reason
// (comes from an unified assembly). When the symbol is not found no error is reported. See test VersionUnification_UseSiteDiagnostics_OptionalAttributes.
bool isOptional = WellKnownMembers.IsSynthesizedAttributeOptional(attributeMember);
GetWellKnownTypeMember(compilation, attributeMember, diagnostics, location, syntax, isOptional);
}