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

lucaslorentz / minicover / #192

23 Dec 2024 10:19AM UTC coverage: 35.027% (-0.03%) from 35.054%
#192

push

azure-devops

web-flow
Merge pull request #179 from lucaslorentz/source-generators-fix

Source generators fix

0 of 7 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

903 of 2578 relevant lines covered (35.03%)

7705.11 hits per line

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

0.0
/src/MiniCover.Core/Extensions/DocumentExtensions.cs
1
using System.IO;
2
using System.Linq;
3
using System.Security.Cryptography;
4
using Mono.Cecil.Cil;
5

6
namespace MiniCover.Core.Extensions
7
{
8
    public static class DocumentExtensions
9
    {
10
        public static bool FileHasChanged(this Document document)
11
        {
12
            if (!File.Exists(document.Url))
×
13
            {
14
                // Ignore not found source generated files because they might be in memory
NEW
15
                if (document.Url.EndsWith(".g.cs"))
×
NEW
16
                    return false;
×
17

UNCOV
18
                return true;
×
19
            }
20

21
            using (var stream = File.OpenRead(document.Url))
×
22
            {
23
                var hasher = CreateHashAlgorithm(document.HashAlgorithm);
×
24

25
                if (hasher == null)
×
26
                    return false;
×
27

28
                using (hasher)
×
29
                {
30
                    var newHash = hasher.ComputeHash(stream);
×
31
                    return !newHash.SequenceEqual(document.Hash);
×
32
                }
33
            }
34
        }
35

36
        private static HashAlgorithm CreateHashAlgorithm(DocumentHashAlgorithm algorithm)
37
        {
38
            switch (algorithm)
×
39
            {
40
                case DocumentHashAlgorithm.SHA1: return SHA1.Create();
×
41
                case DocumentHashAlgorithm.SHA256: return SHA256.Create();
×
42
                case DocumentHashAlgorithm.MD5: return MD5.Create();
×
43
                default: return null;
×
44
            }
45
        }
46
    }
47
}
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