/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Compilers/CSharp/Portable/Symbols/Source/LocalFunctionOrSourceMemberMethodSymbol.cs
47 строк
2 KB
Rikki Gibson
Fix some missing attributes on partial async and iterator methods (#83790)
02 июн 2026, 18:47
Не верифицирован
02 июн 2026, 18:47
d6af2a8
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Diagnostics; using System.Threading; namespace Microsoft.CodeAnalysis.CSharp.Symbols { internal abstract class LocalFunctionOrSourceMemberMethodSymbol : SourceMethodSymbol { private TypeWithAnnotations.Boxed? _lazyIteratorElementType; protected LocalFunctionOrSourceMemberMethodSymbol(SyntaxReference? syntaxReferenceOpt, bool isIterator) : base(syntaxReferenceOpt) { if (isIterator) { _lazyIteratorElementType = TypeWithAnnotations.Boxed.Sentinel; } } internal sealed override TypeWithAnnotations IteratorElementTypeWithAnnotations { get { if (_lazyIteratorElementType == TypeWithAnnotations.Boxed.Sentinel) { TypeWithAnnotations elementType = InMethodBinder.GetIteratorElementTypeFromReturnType(DeclaringCompilation, RefKind, ReturnType, errorLocation: null, diagnostics: null); if (elementType.IsDefault) { elementType = TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(DeclaringCompilation, name: "", arity: 0, errorInfo: null, unreported: false)); } Interlocked.CompareExchange(ref _lazyIteratorElementType, new TypeWithAnnotations.Boxed(elementType), TypeWithAnnotations.Boxed.Sentinel); Debug.Assert(TypeSymbol.Equals(_lazyIteratorElementType.Value.Type, elementType.Type, TypeCompareKind.ConsiderEverything)); } return _lazyIteratorElementType?.Value ?? default; } } internal override bool IsIterator => _lazyIteratorElementType is object; } }