mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing some basic fx cop warnings
--HG-- branch : dev
This commit is contained in:
@@ -50,19 +50,25 @@ namespace Orchard.Core.Messaging.Services {
|
||||
Service = service
|
||||
};
|
||||
|
||||
if ( properties != null ) {
|
||||
foreach (var key in properties.Keys)
|
||||
context.Properties.Add(key, properties[key]);
|
||||
try {
|
||||
|
||||
if (properties != null) {
|
||||
foreach (var key in properties.Keys)
|
||||
context.Properties.Add(key, properties[key]);
|
||||
}
|
||||
|
||||
_messageEventHandler.Sending(context);
|
||||
|
||||
foreach (var channel in _channels) {
|
||||
channel.SendMessage(context);
|
||||
}
|
||||
|
||||
_messageEventHandler.Sent(context);
|
||||
}
|
||||
|
||||
_messageEventHandler.Sending(context);
|
||||
|
||||
foreach ( var channel in _channels ) {
|
||||
channel.SendMessage(context);
|
||||
finally {
|
||||
context.MailMessage.Dispose();
|
||||
}
|
||||
|
||||
_messageEventHandler.Sent(context);
|
||||
|
||||
Logger.Information("Message {0} sent", type);
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -13,7 +13,6 @@ namespace Orchard.Core.Routable.Services {
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Slugs should be lowercase.")]
|
||||
public void FillSlugFromTitle<TModel>(TModel model) where TModel : RoutePart {
|
||||
if (!string.IsNullOrEmpty(model.Slug) || string.IsNullOrEmpty(model.Title))
|
||||
return;
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -75,18 +75,19 @@ namespace Orchard.CodeGeneration.Commands {
|
||||
}
|
||||
|
||||
List<SchemaCommand> commands = _schemaCommandGenerator.GetCreateFeatureCommands(featureName, false).ToList();
|
||||
|
||||
var stringWriter = new StringWriter();
|
||||
var interpreter = new CodeGenerationCommandInterpreter(stringWriter);
|
||||
string dataMigrationText;
|
||||
using (var stringWriter = new StringWriter()) {
|
||||
var interpreter = new CodeGenerationCommandInterpreter(stringWriter);
|
||||
|
||||
foreach (var command in commands) {
|
||||
interpreter.Visit(command);
|
||||
stringWriter.WriteLine();
|
||||
foreach (var command in commands) {
|
||||
interpreter.Visit(command);
|
||||
stringWriter.WriteLine();
|
||||
}
|
||||
|
||||
dataMigrationText = File.ReadAllText(templatesPath + "DataMigration.txt");
|
||||
dataMigrationText = dataMigrationText.Replace("$$FeatureName$$", featureName);
|
||||
dataMigrationText = dataMigrationText.Replace("$$Commands$$", stringWriter.ToString());
|
||||
}
|
||||
|
||||
string dataMigrationText = File.ReadAllText(templatesPath + "DataMigration.txt");
|
||||
dataMigrationText = dataMigrationText.Replace("$$FeatureName$$", featureName);
|
||||
dataMigrationText = dataMigrationText.Replace("$$Commands$$", stringWriter.ToString());
|
||||
File.WriteAllText(dataMigrationFilePath, dataMigrationText);
|
||||
|
||||
string projectFileText = File.ReadAllText(moduleCsProjPath);
|
||||
@@ -220,7 +221,7 @@ namespace Orchard.CodeGeneration.Commands {
|
||||
|
||||
foreach(var folder in _moduleDirectories) {
|
||||
Directory.CreateDirectory(modulePath + folder);
|
||||
if (folder != "") {
|
||||
if (!String.IsNullOrEmpty(folder)) {
|
||||
folders.Add(modulePath + folder);
|
||||
}
|
||||
}
|
||||
@@ -266,7 +267,7 @@ namespace Orchard.CodeGeneration.Commands {
|
||||
foreach (var folderName in _themeDirectories) {
|
||||
var folder = themePath + folderName;
|
||||
Directory.CreateDirectory(folder);
|
||||
if (folderName != "") {
|
||||
if (!String.IsNullOrEmpty(folderName)) {
|
||||
createdFolders.Add(folder);
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -34,32 +34,34 @@ namespace Orchard.Email.Services {
|
||||
return;
|
||||
}
|
||||
|
||||
var smtpClient = new SmtpClient { UseDefaultCredentials = !smtpSettings.RequireCredentials };
|
||||
if ( !smtpClient.UseDefaultCredentials && !String.IsNullOrWhiteSpace(smtpSettings.UserName) ) {
|
||||
smtpClient.Credentials = new NetworkCredential(smtpSettings.UserName, smtpSettings.Password);
|
||||
}
|
||||
using (var smtpClient = new SmtpClient()) {
|
||||
smtpClient.UseDefaultCredentials = !smtpSettings.RequireCredentials;
|
||||
if (!smtpClient.UseDefaultCredentials && !String.IsNullOrWhiteSpace(smtpSettings.UserName)) {
|
||||
smtpClient.Credentials = new NetworkCredential(smtpSettings.UserName, smtpSettings.Password);
|
||||
}
|
||||
|
||||
if(context.MailMessage.To.Count == 0) {
|
||||
Logger.Error("Recipient is missing an email address");
|
||||
return;
|
||||
}
|
||||
if (context.MailMessage.To.Count == 0) {
|
||||
Logger.Error("Recipient is missing an email address");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( smtpSettings.Host != null )
|
||||
smtpClient.Host = smtpSettings.Host;
|
||||
if (smtpSettings.Host != null)
|
||||
smtpClient.Host = smtpSettings.Host;
|
||||
|
||||
smtpClient.Port = smtpSettings.Port;
|
||||
smtpClient.EnableSsl = smtpSettings.EnableSsl;
|
||||
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
smtpClient.Port = smtpSettings.Port;
|
||||
smtpClient.EnableSsl = smtpSettings.EnableSsl;
|
||||
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
|
||||
context.MailMessage.From = new MailAddress(smtpSettings.Address);
|
||||
context.MailMessage.IsBodyHtml = context.MailMessage.Body != null && context.MailMessage.Body.Contains("<") && context.MailMessage.Body.Contains(">");
|
||||
context.MailMessage.From = new MailAddress(smtpSettings.Address);
|
||||
context.MailMessage.IsBodyHtml = context.MailMessage.Body != null && context.MailMessage.Body.Contains("<") && context.MailMessage.Body.Contains(">");
|
||||
|
||||
try {
|
||||
smtpClient.Send(context.MailMessage);
|
||||
Logger.Debug("Message sent to {0}: {1}", context.MailMessage.To[0].Address, context.Type);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Logger.Error(e, "An unexpected error while sending a message to {0}: {1}", context.MailMessage.To[0].Address, context.Type);
|
||||
try {
|
||||
smtpClient.Send(context.MailMessage);
|
||||
Logger.Debug("Message sent to {0}: {1}", context.MailMessage.To[0].Address, context.Type);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.Error(e, "An unexpected error while sending a message to {0}: {1}", context.MailMessage.To[0].Address, context.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,16 +27,17 @@ namespace Orchard.Experimental.Controllers {
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Execute(CommandsExecuteViewModel model) {
|
||||
var writer = new StringWriter();
|
||||
var commandLine = model.CommandLine.Trim();
|
||||
CommandParameters parameters = GetCommandParameters(commandLine, writer);
|
||||
using (var writer = new StringWriter()) {
|
||||
var commandLine = model.CommandLine.Trim();
|
||||
CommandParameters parameters = GetCommandParameters(commandLine, writer);
|
||||
|
||||
_commandManager.Execute(parameters);
|
||||
model.History = (model.History ?? Enumerable.Empty<string>())
|
||||
.Concat(new[] { model.CommandLine })
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
model.Results = writer.ToString();
|
||||
_commandManager.Execute(parameters);
|
||||
model.History = (model.History ?? Enumerable.Empty<string>())
|
||||
.Concat(new[] { model.CommandLine })
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
model.Results = writer.ToString();
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@ namespace Orchard.Experimental.Controllers {
|
||||
_contentDefinitionReader = contentDefinitionReader;
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "StringWriter is disposed by wrapped XmlWriter.")]
|
||||
public ActionResult Index() {
|
||||
var model = new MetadataIndexViewModel {
|
||||
TypeDefinitions = _contentDefinitionManager.ListTypeDefinitions(),
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -22,7 +22,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -65,7 +65,7 @@
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Content Include="Module.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@@ -17,7 +17,7 @@ namespace Orchard.Media.Helpers {
|
||||
string[] navigationParts = mediaPath.Split(new[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
string currentPath = String.Empty;
|
||||
foreach (string navigationPart in navigationParts) {
|
||||
currentPath = (currentPath == String.Empty ? navigationPart : currentPath + "\\" + navigationPart);
|
||||
currentPath = (string.IsNullOrEmpty(currentPath) ? navigationPart : currentPath + "\\" + navigationPart);
|
||||
navigations.Add(new FolderNavigation { FolderName = navigationPart, FolderPath = currentPath });
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -115,8 +115,8 @@ namespace Orchard.Media.Services {
|
||||
return false;
|
||||
}
|
||||
var mediaSettings = CurrentSite.As<MediaSettingsPart>();
|
||||
var allowedExtensions = mediaSettings.UploadAllowedFileTypeWhitelist.ToLowerInvariant().Split(' ');
|
||||
var ext = (Path.GetExtension(name) ?? "").TrimStart('.').ToLowerInvariant();
|
||||
var allowedExtensions = mediaSettings.UploadAllowedFileTypeWhitelist.ToUpperInvariant().Split(' ');
|
||||
var ext = (Path.GetExtension(name) ?? "").TrimStart('.').ToUpperInvariant();
|
||||
if (string.IsNullOrWhiteSpace(ext)) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -42,7 +42,6 @@ namespace Orchard.Packaging.Commands {
|
||||
|
||||
using ( var stream = File.Create(filename) ) {
|
||||
packageData.PackageStream.CopyTo(stream);
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
var fileInfo = new FileInfo(filename);
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -204,6 +204,7 @@ namespace Orchard.Packaging.Services {
|
||||
|
||||
public string Path { get { return _packagePath; } }
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Supposed to return an open stream.")]
|
||||
public Stream GetStream() {
|
||||
var stream = new MemoryStream();
|
||||
_webSiteFolder.CopyFileTo(_virtualPath, stream);
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -41,6 +41,7 @@ namespace Orchard.Setup.Controllers {
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "StreamReader closed by XmlTextReader.")]
|
||||
private bool ValidateMachineKey() {
|
||||
// Get the machineKey section.
|
||||
MachineKeySection machineKeySection = null;
|
||||
@@ -59,12 +60,13 @@ namespace Orchard.Setup.Controllers {
|
||||
|| machineKeySection.DecryptionKey.Contains("AutoGenerate")
|
||||
|| machineKeySection.ValidationKey.Contains("AutoGenerate")) {
|
||||
|
||||
var rng = new RNGCryptoServiceProvider();
|
||||
var decryptionData = new byte[32];
|
||||
var validationData = new byte[64];
|
||||
|
||||
rng.GetBytes(decryptionData);
|
||||
rng.GetBytes(validationData);
|
||||
|
||||
using (var rng = new RNGCryptoServiceProvider()) {
|
||||
rng.GetBytes(decryptionData);
|
||||
rng.GetBytes(validationData);
|
||||
}
|
||||
|
||||
string decryptionKey = BitConverter.ToString(decryptionData).Replace("-", "");
|
||||
string validationKey = BitConverter.ToString(validationData).Replace("-", "");
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -212,15 +212,18 @@ namespace Orchard.Users.Services {
|
||||
private static void SetPasswordHashed(UserPartRecord partRecord, string password) {
|
||||
|
||||
var saltBytes = new byte[0x10];
|
||||
var random = new RNGCryptoServiceProvider();
|
||||
random.GetBytes(saltBytes);
|
||||
using (var random = new RNGCryptoServiceProvider()) {
|
||||
random.GetBytes(saltBytes);
|
||||
}
|
||||
|
||||
var passwordBytes = Encoding.Unicode.GetBytes(password);
|
||||
|
||||
var combinedBytes = saltBytes.Concat(passwordBytes).ToArray();
|
||||
|
||||
var hashAlgorithm = HashAlgorithm.Create(partRecord.HashAlgorithm);
|
||||
var hashBytes = hashAlgorithm.ComputeHash(combinedBytes);
|
||||
byte[] hashBytes;
|
||||
using (var hashAlgorithm = HashAlgorithm.Create(partRecord.HashAlgorithm)) {
|
||||
hashBytes = hashAlgorithm.ComputeHash(combinedBytes);
|
||||
}
|
||||
|
||||
partRecord.PasswordFormat = MembershipPasswordFormat.Hashed;
|
||||
partRecord.Password = Convert.ToBase64String(hashBytes);
|
||||
@@ -235,8 +238,10 @@ namespace Orchard.Users.Services {
|
||||
|
||||
var combinedBytes = saltBytes.Concat(passwordBytes).ToArray();
|
||||
|
||||
var hashAlgorithm = HashAlgorithm.Create(partRecord.HashAlgorithm);
|
||||
var hashBytes = hashAlgorithm.ComputeHash(combinedBytes);
|
||||
byte[] hashBytes;
|
||||
using (var hashAlgorithm = HashAlgorithm.Create(partRecord.HashAlgorithm)) {
|
||||
hashBytes = hashAlgorithm.ComputeHash(combinedBytes);
|
||||
}
|
||||
|
||||
return partRecord.Password == Convert.ToBase64String(hashBytes);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSet>..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
|
Reference in New Issue
Block a user