Beispiel #1
0
        public IceboxMatchResults Check()
        {
            var iceboxPath = _assembly.Location;

            var iceboxExistsOnDisk = IceboxIO.ExistsOnDisk(iceboxPath, Name);

            if (iceboxExistsOnDisk == true)
            {
                var contracts = IceboxIO.ReadFromDisk(iceboxPath, Name);
                var results   = FindMatchingTypesToIceboxedContracts(contracts);

                return(results);
            }

            var fileNotFoundResult = new IceboxMatchResults();

            fileNotFoundResult.AddBreakingChange(new IceboxBreakingChange(IceboxBreakingChangeType.FileNotFound));

            return(fileNotFoundResult);
        }
Beispiel #2
0
        private IceboxMatchResults FindMatchingTypesToIceboxedContracts(IReadOnlyCollection <IceboxedContract> contracts)
        {
            var result = new IceboxMatchResults();

            foreach (IceboxedContract contract in contracts)
            {
                Type matchingAssemblyType = FindMatchingAssemblyTypeToIceboxedContract(contract, _assembly.GetTypes());

                if (matchingAssemblyType == null)
                {
                    result.AddBreakingChange(new IceboxBreakingChange(
                                                 IceboxBreakingChangeType.TypeNotFound,
                                                 contract));
                }

                var publicPropertiesOfAssemblyType = IceboxGenerator
                                                     .GetPublicPropertiesOfType(matchingAssemblyType)
                                                     .ToList();

                foreach (IceboxedContractMember contractMember in contract.Members)
                {
                    var matchingProperty =
                        FindMatchingPropertyToIceboxedContractMember(contractMember,
                                                                     publicPropertiesOfAssemblyType);

                    if (matchingProperty == null)
                    {
                        result.AddBreakingChange(new IceboxBreakingChange(
                                                     IceboxBreakingChangeType.TypeNotFound,
                                                     contract,
                                                     contractMember));
                    }
                }
            }

            return(result);
        }