<commit_before>﻿using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;

#pragma warning disable CS0067
static class SourceGeneratorEngine
{
    static readonly SymbolDisplayFormat fullNameDisplayFormat = new(SymbolDisplayGlobalNamespaceStyle.Omitted, SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces);

    public static void GenerateSource(SourceProductionContext context, Configuration configuration, ClassContext classContext)
    {
        if (configuration.IsDisabled)
        {
            return;
        }

        var hintName = classContext.TypeSymbol.ToDisplayString(fullNameDisplayFormat) + ".g.cs";

        Log($"Generate source for: {hintName}");

        var eventInvokerName = configuration.EventInvokerName?.Trim().NullIfEmpty() ?? "OnPropertyChanged";

        var codeBuilder = new CodeBuilder();

        try
        {
            codeBuilder.AddPreamble();

            GenerateCodeForClass(classContext, codeBuilder, eventInvokerName);
        }
        catch (Exception ex)
        {
            codeBuilder.Add("/*");
            codeBuilder.Add($"GenerateSource failed: {ex}");
            codeBuilder.Add("*/");
        }

        try
        {
            context.AddSource(hintName, codeBuilder.ToString());
        }
        catch (ArgumentException)
        {
            // A class with multiple parts that all derive from INPC or have the attribute will result in multiple syntax nodes that all appear to need the generated part.
            // Just skip the duplicate generations.
        }
    }


    public static void GenerateSource(SourceProductionContext context, Configuration configuration, ImmutableArray<ClassContext> classes)
    {
        const string sourceFileHintName = "PropertyChanged.g.cs";

        if (configuration.IsDisabled)<commit_msg>Remove non-functional code, the exception is not thrown here.<commit_after>﻿using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;

#pragma warning disable CS0067
static class SourceGeneratorEngine
{
    static readonly SymbolDisplayFormat fullNameDisplayFormat = new(SymbolDisplayGlobalNamespaceStyle.Omitted, SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces);

    public static void GenerateSource(SourceProductionContext context, Configuration configuration, ClassContext classContext)
    {
        if (configuration.IsDisabled)
        {
            return;
        }

        var hintName = classContext.TypeSymbol.ToDisplayString(fullNameDisplayFormat) + ".g.cs";

        Log($"Generate source for: {hintName}");

        var eventInvokerName = configuration.EventInvokerName?.Trim().NullIfEmpty() ?? "OnPropertyChanged";

        var codeBuilder = new CodeBuilder();

        try
        {
            codeBuilder.AddPreamble();

            GenerateCodeForClass(classContext, codeBuilder, eventInvokerName);
        }
        catch (Exception ex)
        {
            codeBuilder.Add("/*");
            codeBuilder.Add($"GenerateSource failed: {ex}");
            codeBuilder.Add("*/");
        }

        context.AddSource(hintName, codeBuilder.ToString());
    }


    public static void GenerateSource(SourceProductionContext context, Configuration configuration, ImmutableArray<ClassContext> classes)
    {
        const string sourceFileHintName = "PropertyChanged.g.cs";

        if (configuration.IsDisabled)
{'fraction_non_alphanumeric': 0.0829000577700751, 'fraction_numerical': 0.002310803004043905, 'mean_word_length': 3.098224852071006, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6267446', 'n_tokens_mistral': 845, 'n_tokens_neox': 807, 'n_words': 197}