<commit_before>﻿// 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.Runtime.CompilerServices;

namespace Microsoft.CodeAnalysis.CodeGeneration
{
    internal class CodeGenerationPropertyInfo
    {
        private static readonly ConditionalWeakTable<IPropertySymbol, CodeGenerationPropertyInfo> s_propertyToInfoMap =
            new ConditionalWeakTable<IPropertySymbol, CodeGenerationPropertyInfo>();

        private readonly bool _isNew;
        private readonly bool _isUnsafe;
        private readonly SyntaxNode _initializer;

        private CodeGenerationPropertyInfo(
            bool isNew,
            bool isUnsafe,
            SyntaxNode initializer)
        {
            _isNew = isNew;
            _isUnsafe = isUnsafe;
            _initializer = initializer;
        }

        public static void Attach(
            IPropertySymbol property,
            bool isNew,
            bool isUnsafe,
            SyntaxNode initializer)
        {
            var info = new CodeGenerationPropertyInfo(isNew, isUnsafe, initializer);
            s_propertyToInfoMap.Add(property, info);
        }

        private static CodeGenerationPropertyInfo GetInfo(IPropertySymbol property)
        {
            s_propertyToInfoMap.TryGetValue(property, out var info);
            return info;
        }

        public static SyntaxNode GetInitializer(CodeGenerationPropertyInfo info)
        {
            return info == null ? null : info._initializer;
        }

        public static SyntaxNode GetInitializer(IPropertySymbol property)
        {
            return GetInitializer(GetInfo(property));
        }<commit_msg>Simplify expressino<commit_after>﻿// 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.Runtime.CompilerServices;

namespace Microsoft.CodeAnalysis.CodeGeneration
{
    internal class CodeGenerationPropertyInfo
    {
        private static readonly ConditionalWeakTable<IPropertySymbol, CodeGenerationPropertyInfo> s_propertyToInfoMap =
            new ConditionalWeakTable<IPropertySymbol, CodeGenerationPropertyInfo>();

        private readonly bool _isNew;
        private readonly bool _isUnsafe;
        private readonly SyntaxNode _initializer;

        private CodeGenerationPropertyInfo(
            bool isNew,
            bool isUnsafe,
            SyntaxNode initializer)
        {
            _isNew = isNew;
            _isUnsafe = isUnsafe;
            _initializer = initializer;
        }

        public static void Attach(
            IPropertySymbol property,
            bool isNew,
            bool isUnsafe,
            SyntaxNode initializer)
        {
            var info = new CodeGenerationPropertyInfo(isNew, isUnsafe, initializer);
            s_propertyToInfoMap.Add(property, info);
        }

        private static CodeGenerationPropertyInfo GetInfo(IPropertySymbol property)
        {
            s_propertyToInfoMap.TryGetValue(property, out var info);
            return info;
        }

        public static SyntaxNode GetInitializer(CodeGenerationPropertyInfo info)
            => info?._initializer;

        public static SyntaxNode GetInitializer(IPropertySymbol property)
        {
            return GetInitializer(GetInfo(property));
        }
{'fraction_non_alphanumeric': 0.052215636466271524, 'fraction_numerical': 0.0, 'mean_word_length': 2.381679389312977, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4630727', 'n_tokens_mistral': 844, 'n_tokens_neox': 820, 'n_words': 245}