Ejemplo n.º 1
0
        internal InMethodBinder GetRecordConstructorInMethodBinder(SynthesizedRecordConstructor constructor)
        {
            RecordDeclarationSyntax typeDecl = constructor.GetSyntax();

            var extraInfo = NodeUsage.ConstructorBodyOrInitializer;
            var key       = BinderFactoryVisitor.CreateBinderCacheKey(typeDecl, extraInfo);

            if (!_binderCache.TryGetValue(key, out Binder resultBinder))
            {
                // Ctors cannot be generic
                Debug.Assert(constructor.Arity == 0, "Generic Ctor, What to do?");
                resultBinder = new InMethodBinder(constructor, GetInRecordBodyBinder(typeDecl));

                _binderCache.TryAdd(key, resultBinder);
            }

            return((InMethodBinder)resultBinder);
        }