Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-364) Only update the config if changed
  (resharper) line breaks at 195 characters
  (maint) formatting
  • Loading branch information
ferventcoder committed Sep 18, 2015
2 parents aeb856b + d5dd42f commit f76d9cd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/chocolatey.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=sensible/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="sensible"&gt;&lt;CSArrangeThisQualifier&gt;True&lt;/CSArrangeThisQualifier&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSRemoveCodeRedundancies&gt;True&lt;/CSRemoveCodeRedundancies&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;CSUseVar&gt;&lt;BehavourStyle&gt;CAN_CHANGE_TO_IMPLICIT&lt;/BehavourStyle&gt;&lt;LocalVariableStyle&gt;IMPLICIT_WHEN_INITIALIZER_HAS_TYPE&lt;/LocalVariableStyle&gt;&lt;ForeachVariableStyle&gt;ALWAYS_EXPLICIT&lt;/ForeachVariableStyle&gt;&lt;/CSUseVar&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">sensible</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CommonFormatter/USE_INDENTS_FROM_MAIN_LANGUAGE_IN_FILE/@EntryValue">False</s:Boolean>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">220</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">195</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AddImportsToDeepestScope/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">Copyright © 2011 - Present RealDimensions Software, LLC&#xD;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
namespace chocolatey.tests.integration.infrastructure.app.services
// Copyright © 2011 - Present RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace chocolatey.tests.integration.infrastructure.app.services
{
using System;
using System.IO;
Expand All @@ -9,7 +24,6 @@
using chocolatey.infrastructure.app.configuration;
using chocolatey.infrastructure.app.domain;
using chocolatey.infrastructure.app.services;
using chocolatey.infrastructure.commands;
using chocolatey.infrastructure.cryptography;
using chocolatey.infrastructure.filesystem;
using chocolatey.infrastructure.results;
Expand All @@ -21,10 +35,12 @@ public abstract class FilesServiceSpecsBase : TinySpec
{
protected FilesService Service;
protected IFileSystem FileSystem = new DotNetFileSystem();
protected IHashProvider HashProvider;

public override void Context()
{
Service = new FilesService(new XmlService(FileSystem), FileSystem, new CrytpoHashProvider(FileSystem, CryptoHashProviderType.Md5));
HashProvider = new CrytpoHashProvider(FileSystem, CryptoHashProviderType.Md5);
Service = new FilesService(new XmlService(FileSystem, HashProvider), FileSystem, new CrytpoHashProvider(FileSystem, CryptoHashProviderType.Md5));
}
}

Expand Down Expand Up @@ -89,4 +105,4 @@ public void should_return_a_special_code_for_locked_files()
}
}
}
}
}
11 changes: 9 additions & 2 deletions src/chocolatey/infrastructure/services/XmlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.services
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using cryptography;
using filesystem;
using tolerance;

Expand All @@ -28,10 +29,12 @@ namespace chocolatey.infrastructure.services
public sealed class XmlService : IXmlService
{
private readonly IFileSystem _fileSystem;
private readonly IHashProvider _hashProvider;

public XmlService(IFileSystem fileSystem)
public XmlService(IFileSystem fileSystem, IHashProvider hashProvider)
{
_fileSystem = fileSystem;
_hashProvider = hashProvider;
}

public XmlType deserialize<XmlType>(string xmlFilePath)
Expand Down Expand Up @@ -74,7 +77,11 @@ public void serialize<XmlType>(XmlType xmlType, string xmlFilePath)
textWriter.Close();
textWriter.Dispose();

_fileSystem.copy_file(xmlUpdateFilePath, xmlFilePath, overwriteExisting: true);
if (!_hashProvider.hash_file(xmlFilePath).is_equal_to(_hashProvider.hash_file(xmlUpdateFilePath)))
{
_fileSystem.copy_file(xmlUpdateFilePath, xmlFilePath, overwriteExisting: true);
}

_fileSystem.delete_file(xmlUpdateFilePath);
},
"Error serializing type {0}".format_with(typeof(XmlType)),
Expand Down

0 comments on commit f76d9cd

Please sign in to comment.