コード例 #1
0
        public override bool TryGetPreviousHoistedLocalSlotIndex(
            SyntaxNode currentDeclarator,
            Cci.ITypeReference currentType,
            SynthesizedLocalKind synthesizedKind,
            LocalDebugId currentId,
            DiagnosticBag diagnostics,
            out int slotIndex)
        {
            // The previous method was not a state machine (it is allowed to change non-state machine to a state machine):
            if (_hoistedLocalSlots == null)
            {
                slotIndex = -1;
                return(false);
            }

            if (!TryGetPreviousLocalId(currentDeclarator, currentId, out LocalDebugId previousId))
            {
                slotIndex = -1;
                return(false);
            }

            var previousType = _symbolMap.MapReference(currentType);

            if (previousType == null)
            {
                slotIndex = -1;
                return(false);
            }

            // TODO (bug #781309): Should report a warning if the type of the local has changed
            // and the previous value will be dropped.
            var localKey = new EncHoistedLocalInfo(new LocalSlotDebugInfo(synthesizedKind, previousId), previousType);

            return(_hoistedLocalSlots.TryGetValue(localKey, out slotIndex));
        }
コード例 #2
0
        public override int GetPreviousHoistedLocalSlotIndex(SyntaxNode currentDeclarator, Cci.ITypeReference currentType, SynthesizedLocalKind synthesizedKind, LocalDebugId currentId)
        {
            Debug.Assert(_hoistedLocalSlotsOpt != null);

            LocalDebugId previousId;

            if (!TryGetPreviousLocalId(currentDeclarator, currentId, out previousId))
            {
                return(-1);
            }

            var previousType = _symbolMap.MapReference(currentType);

            if (previousType == null)
            {
                return(-1);
            }

            // TODO (bug #781309): Should report a warning if the type of the local has changed
            // and the previous value will be dropped.
            var localKey = new EncHoistedLocalInfo(new LocalSlotDebugInfo(synthesizedKind, previousId), previousType);

            int slotIndex;

            if (!_hoistedLocalSlotsOpt.TryGetValue(localKey, out slotIndex))
            {
                return(-1);
            }

            return(slotIndex);
        }
コード例 #3
0
        private static EncHoistedLocalInfo MapHoistedLocalSlot(EncHoistedLocalInfo info, SymbolMatcher map)
        {
            if (info.IsUnused)
            {
                return(info);
            }

            return(new EncHoistedLocalInfo(info.SlotInfo, map.MapReference(info.Type)));
        }
コード例 #4
0
        public override bool TryGetPreviousHoistedLocalSlotIndex(
            SyntaxNode currentDeclarator,
            Cci.ITypeReference currentType,
            SynthesizedLocalKind synthesizedKind,
            LocalDebugId currentId,
            DiagnosticBag diagnostics,
            out int slotIndex)
        {
            // Well-formed state machine attribute wasn't found in the baseline (the type is missing or bad).
            // Should rarely happen since the IDE reports a rude edit if the attribute type doesn't exist.
            if (_hoistedLocalSlotsOpt == null)
            {
                // TODO: better error message https://github.com/dotnet/roslyn/issues/9196
                diagnostics.Add(_messageProvider.CreateDiagnostic(_messageProvider.ERR_ModuleEmitFailure, NoLocation.Singleton, _previousTopLevelMethod.ContainingModule.Name));
                slotIndex = -1;
                return(false);
            }

            LocalDebugId previousId;

            if (!TryGetPreviousLocalId(currentDeclarator, currentId, out previousId))
            {
                slotIndex = -1;
                return(false);
            }

            var previousType = _symbolMap.MapReference(currentType);

            if (previousType == null)
            {
                slotIndex = -1;
                return(false);
            }

            // TODO (bug #781309): Should report a warning if the type of the local has changed
            // and the previous value will be dropped.
            var localKey = new EncHoistedLocalInfo(new LocalSlotDebugInfo(synthesizedKind, previousId), previousType);

            return(_hoistedLocalSlotsOpt.TryGetValue(localKey, out slotIndex));
        }
コード例 #5
0
        public override bool TryGetPreviousHoistedLocalSlotIndex(
            SyntaxNode currentDeclarator,
            Cci.ITypeReference currentType,
            SynthesizedLocalKind synthesizedKind,
            LocalDebugId currentId,
            DiagnosticBag diagnostics,
            out int slotIndex)
        {
            // Well-formed state machine attribute wasn't found in the baseline (the type is missing or bad).
            // Should rarely happen since the IDE reports a rude edit if the attribute type doesn't exist.
            if (_hoistedLocalSlotsOpt == null)
            {
                ReportMissingStateMachineAttribute(diagnostics);
                slotIndex = -1;
                return(false);
            }

            LocalDebugId previousId;

            if (!TryGetPreviousLocalId(currentDeclarator, currentId, out previousId))
            {
                slotIndex = -1;
                return(false);
            }

            var previousType = _symbolMap.MapReference(currentType);

            if (previousType == null)
            {
                slotIndex = -1;
                return(false);
            }

            // TODO (bug #781309): Should report a warning if the type of the local has changed
            // and the previous value will be dropped.
            var localKey = new EncHoistedLocalInfo(new LocalSlotDebugInfo(synthesizedKind, previousId), previousType);

            return(_hoistedLocalSlotsOpt.TryGetValue(localKey, out slotIndex));
        }