Esempio n. 1
0
 internal static CSDiagnosticInfo Add(this DiagnosticBag diagnostics, ErrorCode code, Location location, ImmutableArray<Symbol> symbols, params object[] args)
 {
     var info = new CSDiagnosticInfo(code, args, symbols, ImmutableArray<Location>.Empty);
     var diag = new CSDiagnostic(info, location);
     diagnostics.Add(diag);
     return info;
 }
Esempio n. 2
0
        private static PropertySymbol GetCustomTaskProperty(
            SyntheticBoundNodeFactory F,
            NamedTypeSymbol builderType)
        {
            const string propertyName = "Task";
            var          members      = builderType.GetMembers(propertyName);

            foreach (var member in members)
            {
                if (member.Kind != SymbolKind.Property)
                {
                    continue;
                }
                var property = (PropertySymbol)member;
                if ((property.DeclaredAccessibility == Accessibility.Public) &&
                    !property.IsStatic &&
                    (property.ParameterCount == 0))
                {
                    return(property);
                }
            }
            var diagnostic = new CSDiagnostic(
                new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, builderType, propertyName),
                F.Syntax.Location);

            F.Diagnostics.Add(diagnostic);
            return(null);
        }
Esempio n. 3
0
 /// <summary>
 /// Add a diagnostic to the bag.
 /// </summary>
 /// <param name="diagnostics"></param>
 /// <param name="code"></param>
 /// <param name="location"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 internal static CSDiagnosticInfo Add(this DiagnosticBag diagnostics, ErrorCode code, Location location, params object[] args)
 {
     var info = new CSDiagnosticInfo(code, args);
     var diag = new CSDiagnostic(info, location);
     diagnostics.Add(diag);
     return info;
 }
        private static bool TryGetBuilderMember <TSymbol>(
            SyntheticBoundNodeFactory F,
            WellKnownMember?member,
            NamedTypeSymbol builderType,
            bool customBuilder,
            out TSymbol symbol
            ) where TSymbol : Symbol
        {
            if (!member.HasValue)
            {
                symbol = null;
                return(true);
            }

            WellKnownMember memberValue = member.Value;

            if (customBuilder)
            {
                var descriptor = WellKnownMembers.GetDescriptor(memberValue);
                var sym        = CSharpCompilation.GetRuntimeMember(
                    builderType.OriginalDefinition,
                    descriptor,
                    F.Compilation.WellKnownMemberSignatureComparer,
                    accessWithinOpt: null
                    );
                if ((object)sym != null)
                {
                    sym = sym.SymbolAsMember(builderType);
                }
                symbol = sym as TSymbol;
            }
            else
            {
                symbol = F.WellKnownMember(memberValue, isOptional: true) as TSymbol;
                if ((object)symbol != null)
                {
                    symbol = (TSymbol)symbol.SymbolAsMember(builderType);
                }
            }
            if ((object)symbol == null)
            {
                var descriptor = WellKnownMembers.GetDescriptor(memberValue);
                var diagnostic = new CSDiagnostic(
                    new CSDiagnosticInfo(
                        ErrorCode.ERR_MissingPredefinedMember,
                        (
                            customBuilder
                                ? (object)builderType
                                : descriptor.DeclaringTypeMetadataName
                        ),
                        descriptor.Name
                        ),
                    F.Syntax.Location
                    );
                F.Diagnostics.Add(diagnostic);
                return(false);
            }
            return(true);
        }
        internal static CSDiagnosticInfo Add(this DiagnosticBag diagnostics, ErrorCode code, Location location, ImmutableArray <Symbol> symbols, params object[] args)
        {
            var info = new CSDiagnosticInfo(code, args, symbols, ImmutableArray <Location> .Empty);
            var diag = new CSDiagnostic(info, location);

            diagnostics.Add(diag);
            return(info);
        }
        /// <summary>
        /// Add a diagnostic to the bag.
        /// </summary>
        /// <param name="diagnostics"></param>
        /// <param name="code"></param>
        /// <param name="location"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        internal static CSDiagnosticInfo Add(this DiagnosticBag diagnostics, ErrorCode code, Location location, params object[] args)
        {
            var info = new CSDiagnosticInfo(code, args);
            var diag = new CSDiagnostic(info, location);

            diagnostics.Add(diag);
            return(info);
        }
Esempio n. 7
0
        internal static void Add(
            this DiagnosticBag diagnostics,
            DiagnosticInfo info,
            Location location
            )
        {
            var diag = new CSDiagnostic(info, location);

            diagnostics.Add(diag);
        }
        /// <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);
        }
        /// <summary>
        /// Get the symbol for a special member. The use of this method to get a special 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="sm">The desired special member</param>
        /// <returns>A symbol for the special member.</returns>
        public Symbol SpecialMember(SpecialMember sm)
        {
            Symbol specialMember = Compilation.GetSpecialTypeMember(sm);

            if (specialMember == null)
            {
                RuntimeMembers.MemberDescriptor memberDescriptor = SpecialMembers.GetDescriptor(sm);
                SpecialType containingType = (SpecialType)memberDescriptor.DeclaringTypeId;
                var         diagnostic     = new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, containingType.GetMetadataName(), memberDescriptor.Name), Syntax.Location);
                throw new MissingPredefinedMember(diagnostic);
            }

            Binder.ReportUseSiteDiagnostics(specialMember, Diagnostics, Syntax);
            return(specialMember);
        }
        /// <summary>
        /// Get the symbol for a special member. The use of this method to get a special 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="sm">The desired special member</param>
        /// <returns>A symbol for the special member.</returns>
        public Symbol SpecialMember(SpecialMember sm)
        {
            Symbol specialMember = Compilation.GetSpecialTypeMember(sm);
            if (specialMember == null)
            {
                RuntimeMembers.MemberDescriptor memberDescriptor = SpecialMembers.GetDescriptor(sm);
                SpecialType containingType = (SpecialType)memberDescriptor.DeclaringTypeId;
                var diagnostic = new CSDiagnostic(new CSDiagnosticInfo(ErrorCode.ERR_MissingPredefinedMember, containingType.GetMetadataName(), memberDescriptor.Name), Syntax.Location);
                throw new MissingPredefinedMember(diagnostic);
            }

            Binder.ReportUseSiteDiagnostics(specialMember, Diagnostics, Syntax);
            return specialMember;
        }
        /// <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;
        }
Esempio n. 12
0
 private void AddDiagnostic(ErrorCode code, Location location, params object[] args)
 {
     var info = new CSDiagnosticInfo(code, args);
     var diag = new CSDiagnostic(info, location);
     _diagnostics.Enqueue(diag);
 }
Esempio n. 13
0
 private void AddDiagnostic(ErrorCode code, Location location)
 {
     var info = new CSDiagnosticInfo(code);
     var diag = new CSDiagnostic(info, location);
     _diagnostics.Enqueue(diag);
 }
Esempio n. 14
0
 internal static void Add(this DiagnosticBag diagnostics, DiagnosticInfo info, Location location)
 {
     var diag = new CSDiagnostic(info, location);
     diagnostics.Add(diag);
 }
 private void AddDiagnostic(ErrorCode code, Location location, params object[] args)
 {
     var info = new CSDiagnosticInfo(code, args, ImmutableArray<Symbol>.Empty, ImmutableArray<Location>.Empty);
     var diag = new CSDiagnostic(info, location);
     this.diagnostics.Enqueue(diag);
 }