• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / EntityFrameworkCore.Generator / 15403562343

02 Jun 2025 09:51PM UTC coverage: 54.917% (+0.08%) from 54.841%
15403562343

push

github

pwelter34
test fix

643 of 1333 branches covered (48.24%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

5 existing lines in 3 files now uncovered.

1881 of 3263 relevant lines covered (57.65%)

61.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.44
/src/EntityFrameworkCore.Generator.Core/Parsing/RegionReplace.cs
1
using System.Text;
2

3
namespace EntityFrameworkCore.Generator.Parsing;
4

5
public class RegionReplace
6
{
7
    public void MergeFile(string fullPath, string outputContent)
8
    {
9
        if (string.IsNullOrEmpty(fullPath) || string.IsNullOrEmpty(outputContent) || !Path.Exists(fullPath))
23!
UNCOV
10
            return;
×
11

12
        var originalContent = File.ReadAllText(fullPath);
23✔
13

14
        var finalContent = MergeContent(originalContent, outputContent);
23✔
15

16
        File.WriteAllText(fullPath, finalContent);
23✔
17
    }
23✔
18

19
    public string MergeContent(string originalContent, string outputContent)
20
    {
21
        if (string.IsNullOrEmpty(originalContent) || string.IsNullOrEmpty(outputContent))
23!
UNCOV
22
            return originalContent;
×
23

24
        var outputRegions = RegionParser.ParseRegions(outputContent);
23✔
25

26
        var originalRegions = RegionParser.ParseRegions(originalContent);
23✔
27
        var originalBuilder = new StringBuilder(originalContent);
23✔
28

29
        int offset = 0;
23✔
30
        foreach (var outputRegion in outputRegions)
160✔
31
        {
32
            var originalRegion = originalRegions
57✔
33
                .Find(r =>
57✔
34
                    string.Equals(r.RegionName, outputRegion.RegionName, StringComparison.OrdinalIgnoreCase)
102✔
35
                    && r.ClassName == outputRegion.ClassName
102✔
36
                );
57✔
37

38
            if (originalRegion == null)
57✔
39
            {
40
                // log error
41
                continue;
42
            }
43

44
            int startIndex = originalRegion.StartIndex + offset;
57✔
45
            int beforeReplace = originalBuilder.Length;
57✔
46
            int length = (originalRegion.EndIndex + offset) - startIndex;
57✔
47

48
            originalBuilder.Remove(startIndex, length);
57✔
49
            originalBuilder.Insert(startIndex, outputRegion.Content);
57✔
50

51
            int afterReplace = originalBuilder.Length;
57✔
52

53
            offset += (afterReplace - beforeReplace);
57✔
54
        }
55

56
        var finalContent = originalBuilder.ToString();
23✔
57

58
        if (originalContent == finalContent)
23✔
59
            return finalContent;
23✔
60

61
        return finalContent;
62
    }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc