--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-11-12 15:37:56 -08:00
84 changed files with 21935 additions and 21948 deletions

View File

@@ -44,16 +44,25 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\autofac\Autofac.dll</HintPath>
</Reference>
<Reference Include="Autofac.Configuration, Version=2.2.4.900, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\autofac\Autofac.Configuration.dll</HintPath>
</Reference>
<Reference Include="Autofac.Integration.Web">
<HintPath>..\..\..\lib\autofac\Autofac.Integration.Web.dll</HintPath>
</Reference>
<Reference Include="Autofac.Integration.Web.Mvc">
<HintPath>..\..\..\lib\autofac\Autofac.Integration.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="IronRuby">
<HintPath>..\..\..\lib\dlr\IronRuby.dll</HintPath>
</Reference>
<Reference Include="IronRuby.Libraries, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\dlr\IronRuby.Libraries.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Dynamic">
<HintPath>..\..\..\lib\dlr\Microsoft.Dynamic.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Scripting">
<HintPath>..\..\..\lib\dlr\Microsoft.Scripting.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>False</Private>

View File

@@ -15,13 +15,6 @@
</sectionGroup>
</configSections>
<appSettings>
<!--
This is a workaround. Theres a known issue that causes Forms Authentication to always redirect unauthenticated users
to ~/Account/Login, ignoring the forms authentication setting used in Web.config.
-->
<add key="autoFormsAuthentication" value="false" />
</appSettings>
<system.diagnostics configSource="Config\Diagnostics.config"/>
<system.web.webPages.razor>
@@ -65,6 +58,26 @@
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<remove assembly="mscorlib" />
<remove assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove assembly="System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove assembly="System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove assembly="System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove assembly="System.WorkflowServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<remove assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
<!--
@@ -76,14 +89,6 @@
<forms loginUrl="~/Users/Account/AccessDenied" timeout="2880"/>
</authentication>
<roleManager enabled="false">
<providers>
<clear/>
<add name="OrchardRoleProvider" type="Orchard.Security.Providers.OrchardRoleProvider, Orchard.Framework"/>
<!--<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>-->
<!--<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>-->
</providers>
</roleManager>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
@@ -104,11 +109,11 @@
</namespaces>
</pages>
<httpHandlers>
<add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<!-- see below -->
<clear />
<add path="default.aspx" verb="*" type="System.Web.UI.PageHandlerFactory" validate="true" />
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
<!-- Block access to module and theme definition files -->
<add verb="*" path="module.txt" validate="false" type="System.Web.HttpNotFoundHandler" />
<add verb="*" path="theme.txt" validate="false" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
</system.web>
<system.web.extensions/>
@@ -118,16 +123,13 @@
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
</modules>
<handlers>
<remove name="MvcHttpHandler"/>
<remove name="UrlRoutingHandler"/>
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
<!-- Block access to module and theme definition files -->
<add name="moduleHttpNotFoundHandler" preCondition="integratedMode" verb="*" path="module.txt" type="System.Web.HttpNotFoundHandler" />
<add name="themeHttpNotFoundHandler" preCondition="integratedMode" verb="*" path="theme.txt" type="System.Web.HttpNotFoundHandler" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers accessPolicy="Script">
<!-- clear all handlers, prevents executing code file extensions, prevents returning any file contents -->
<clear/>
<!-- Return 404 for all requests via managed handler. The url routing handler will substitute the mvc request handler when routes match. -->
<add name="Default" path="default.aspx" verb="*" type="System.Web.UI.PageHandlerFactory" preCondition="integratedMode" requireAccess="Script"/>
<add name="NotFound" path="*" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script"/>
</handlers>
</system.webServer>
<runtime>

View File

@@ -41,7 +41,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

View File

@@ -42,7 +42,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@@ -41,7 +41,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

View File

@@ -41,7 +41,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

View File

@@ -41,7 +41,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

View File

@@ -41,7 +41,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

View File

@@ -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 ) {

View File

@@ -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>

View File

@@ -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;

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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);
}
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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);
}
}
}

View File

@@ -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);
}

View File

@@ -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(),

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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 });
}

View File

@@ -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>

View File

@@ -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;
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -1,4 +1,6 @@
using System.IO;
using System;
using System.IO;
using System.Web;
using System.Web.Hosting;
using Orchard.Commands;
using Orchard.Environment.Extensions;
@@ -42,7 +44,6 @@ namespace Orchard.Packaging.Commands {
using ( var stream = File.Create(filename) ) {
packageData.PackageStream.CopyTo(stream);
stream.Close();
}
var fileInfo = new FileInfo(filename);
@@ -53,21 +54,34 @@ namespace Orchard.Packaging.Commands {
[CommandName("package install")]
[OrchardSwitches("Version")]
public void InstallPackage(string packageId, string location) {
_packageManager.Install(packageId, Version, Path.GetFullPath(location), ApplicationPath);
foreach(var message in _notifier.List()) {
Context.Output.WriteLine(message.Message);
try {
_packageManager.Install(packageId, Version, Path.GetFullPath(location), ApplicationPath);
foreach (var message in _notifier.List()) {
Context.Output.WriteLine(message.Message);
}
}
catch(Exception e) {
// Exceptions area thrown by NuGet as error messages
Context.Output.WriteLine(HttpUtility.HtmlDecode(T("Could not install the package: {0}", e.Message).Text));
}
}
[CommandHelp("package uninstall <packageId> \r\n\t" + "Uninstall a module or a theme.")]
[CommandName("package uninstall")]
public void UninstallPackage(string packageId) {
_packageManager.Uninstall(packageId, ApplicationPath);
try {
_packageManager.Uninstall(packageId, ApplicationPath);
foreach ( var message in _notifier.List() ) {
Context.Output.WriteLine(message.Message);
foreach ( var message in _notifier.List() ) {
Context.Output.WriteLine(message.Message);
}
}
catch(Exception e) {
// Exceptions area thrown by NuGet as error messages
Context.Output.WriteLine(HttpUtility.HtmlDecode(T("Could not unintall the package: {0}", e.Message).Text));
}
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Web.Hosting;
using System.Web.Mvc;
using System.Xml.Linq;
using Orchard.Environment.Extensions;
@@ -126,54 +127,16 @@ namespace Orchard.Packaging.Controllers {
});
}
public ActionResult Harvest(string extensionName, string feedUrl) {
return View(new PackagingHarvestViewModel {
ExtensionName = extensionName,
FeedUrl = feedUrl,
Sources = _packagingSourceManager.GetSources(),
Extensions = _extensionManager.AvailableExtensions()
});
}
public ActionResult Install(string packageId, string version, int sourceId, string redirectTo) {
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
[HttpPost]
public ActionResult Harvest(PackagingHarvestViewModel model) {
#if REFACTORING
model.Sources = _packagingSourceManager.GetSources();
model.Extensions = _extensionManager.AvailableExtensions();
var packageData = _packageManager.Harvest(model.ExtensionName);
if (string.IsNullOrEmpty(model.FeedUrl)) {
return new DownloadStreamResult(
packageData.ExtensionName + "-" + packageData.ExtensionVersion + ".zip",
"application/x-package",
packageData.PackageStream);
if(source == null) {
return HttpNotFound();
}
if (!model.Sources.Any(src => src.FeedUrl == model.FeedUrl)) {
ModelState.AddModelError("FeedUrl", T("May only push directly to one of the configured sources.").ToString());
return View(model);
}
_packageManager.Install(packageId, version, source.FeedUrl, HostingEnvironment.MapPath("~/"));
_packageManager.Push(packageData, model.FeedUrl, model.User, model.Password);
_notifier.Information(T("Harvested {0} and published onto {1}", model.ExtensionName, model.FeedUrl));
Update(null);
return RedirectToAction("Harvest", new { model.ExtensionName, model.FeedUrl });
#else
return View();
#endif
}
public ActionResult Install(string syndicationId, string cameFrom) {
#if REFACTORING
var packageData = _packageManager.Download(syndicationId);
_packageManager.Install(packageData.PackageStream);
_notifier.Information(T("Installed module"));
#endif
return RedirectToAction(cameFrom == "Themes" ? "ThemesIndex" : "ModulesIndex");
return RedirectToAction(redirectTo == "Themes" ? "Themes" : "Modules");
}
}
}

View File

@@ -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>
@@ -108,10 +108,8 @@
<Content Include="Module.txt" />
<Content Include="Styles\admin.css" />
<Content Include="Views\Gallery\AddSource.cshtml" />
<Content Include="Views\Gallery\Harvest.cshtml" />
<Content Include="Views\Gallery\Modules.cshtml" />
<Content Include="Views\Gallery\Sources.cshtml" />
<Content Include="Views\Gallery\_Subnav.cshtml" />
<Content Include="Views\Web.config" />
</ItemGroup>
<ItemGroup />

View File

@@ -1,7 +1,7 @@
namespace Orchard.Packaging.Services {
public interface IPackageManager : IDependency {
PackageData Harvest(string extensionName);
PackageInfo Install(string packageId, string version, string location, string solutionFolder);
void Uninstall(string packageId, string solutionFolder);
PackageInfo Install(string packageId, string version, string location, string applicationPath);
void Uninstall(string packageId, string applicationPath);
}
}

View File

@@ -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);

View File

@@ -72,7 +72,7 @@ namespace Orchard.Packaging.Services {
var project = new FileBasedProjectSystem(applicationPath) { Logger = logger };
var projectManager = new ProjectManager(
sourceRepository, // source repository for the package to install
new DefaultPackagePathResolver(location),
new DefaultPackagePathResolver(applicationPath),
project,
new ExtensionReferenceRepository(project, sourceRepository, _extensionManager)
) {Logger = logger};

View File

@@ -33,12 +33,12 @@ namespace Orchard.Packaging.Services {
};
}
public PackageInfo Install(string packageId, string version, string location, string solutionFolder) {
return _packageExpander.Install(packageId, version, location, solutionFolder);
public PackageInfo Install(string packageId, string version, string location, string applicationPath) {
return _packageExpander.Install(packageId, version, location, applicationPath);
}
public void Uninstall(string packageId, string solutionFolder) {
_packageExpander.Uninstall(packageId, solutionFolder);
public void Uninstall(string packageId, string applicationPath) {
_packageExpander.Uninstall(packageId, applicationPath);
}
#endregion
}

View File

@@ -1,32 +0,0 @@
@model Orchard.Packaging.ViewModels.PackagingHarvestViewModel
<h1>
@Html.TitleForPage(T("Packaging").ToString(), T("Harvest Packages").ToString())</h1>
@Html.Partial("_Subnav", Model)
@using (Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary(T("Package creation was unsuccessful. Please correct the errors and try again.").ToString())
foreach (var group in Model.Extensions.Where(x => !x.Location.StartsWith("~/Core")).GroupBy(x => x.ExtensionType)) {
<fieldset>
<legend>@T("Harvest") @group.Key</legend>
<ul>
@foreach (var item in group) {
<li>
<label>
@Html.RadioButtonFor(m=>m.ExtensionName, item.Name, new Dictionary<string, object>{{"id",item.Name}})
@item.DisplayName
</label>
</li>
}
</ul>
@Html.ValidationMessageFor(m => m.ExtensionName)
</fieldset>
}
<fieldset>
@Html.LabelFor(m => m.FeedUrl, T("Feed Url"))
@Html.DropDownListFor(m => m.FeedUrl, new[]{new SelectListItem{Text=T("Download").ToString(),Value=""}}.Concat( Model.Sources.Select(x => new SelectListItem { Text = T("Push to {0}", x.FeedUrl).ToString(), Value = x.FeedUrl })))
@Html.ValidationMessageFor(m=>m.FeedUrl)
</fieldset>
<fieldset>
<button class="primaryAction" type="submit">@T("Harvest")</button>
</fieldset>
}

View File

@@ -28,14 +28,14 @@
</div>
<div class="related">
@Html.ActionLink(T("Install").ToString(), "Install", new RouteValueDictionary {{"SyndicationId", item.PackageId},{"cameFrom", "Modules"}})@T(" | ")
@Html.ActionLink(T("Install").ToString(), "Install", new RouteValueDictionary {{"packageId", item.PackageId}, {"version", item.Version}, {"sourceId", item.Source.Id}, {"cameFrom", "Modules"}})@T(" | ")
<a href="@item.PackageStreamUri">@T("Download")</a>
</div>
<div class="properties">
<p>@(item.Description == null ? T("(No description").Text : item.Description)</p>
<ul class="pageStatus">
@*todo: (sebros) find a way to get the update date*@<li style="color:red">@T("Last Updated: {0}", DateTime.Now.ToLocalTime())</li>
<li>@T("Last Updated: {0}", DateTime.Now.ToLocalTime())</li>
<li>&nbsp;&#124;&nbsp;@T("Author: {0}", item.Authors)</li>
</ul>
</div>

View File

@@ -35,7 +35,7 @@
<div class="properties">
<p>@(item.Description == null ? T("(No description").Text : item.Description)</p>
<ul class="pageStatus">
@*todo: (sebros) find a way to get the update date*@<li style="color:red">@T("Last Updated: {0}", DateTime.Now.ToLocalTime())</li>
<li>@T("Last Updated: {0}", DateTime.Now.ToLocalTime())</li>
<li>&nbsp;&#124;&nbsp;@T("Author: {0}", item.Authors)</li>
</ul>
</div>

View File

@@ -1,8 +0,0 @@
@model Orchard.Packaging.ViewModels.PackagingHarvestViewModel
<p>
@Html.ActionLink(T("Browse Repository Packages").ToString(), "Index")
&bull;
@Html.ActionLink(T("Harvest Local Packages").ToString(), "Harvest")
&bull;
@Html.ActionLink(T("Edit Repository Sources").ToString(), "Sources")
</p>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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("-", "");

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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);
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -21,14 +21,6 @@
<reflection-optimizer use="false"/>
</hibernate-configuration>
<appSettings>
<!--
This is a workaround. Theres a known issue that causes Forms Authentication to always redirect unauthenticated users
to ~/Account/Login, ignoring the forms authentication setting used in Web.config.
-->
<add key="autoFormsAuthentication" value="false" />
</appSettings>
<system.diagnostics configSource="Config\Diagnostics.config"/>
<system.web.webPages.razor>
@@ -104,15 +96,7 @@
<authentication mode="Forms">
<forms loginUrl="~/Users/Account/AccessDenied" timeout="2880"/>
</authentication>
<roleManager enabled="false">
<providers>
<clear/>
<add name="OrchardRoleProvider" type="Orchard.Security.Providers.OrchardRoleProvider, Orchard.Framework"/>
<!--<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>-->
<!--<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>-->
</providers>
</roleManager>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs

View File

@@ -135,6 +135,7 @@ namespace Orchard.Commands {
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
private IContainer CreateHostContainer() {
var hostContainer = OrchardStarter.CreateHostContainer(ContainerRegistrations);

View File

@@ -20,6 +20,8 @@ namespace Orchard.Commands {
Invoke(context);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "System.Int32.TryParse(System.String,System.Int32@)")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "System.Boolean.TryParse(System.String,System.Boolean@)")]
private void SetSwitchValues(CommandContext context) {
if (context.Switches != null && context.Switches.Any()) {
foreach (var commandSwitch in context.Switches) {
@@ -32,11 +34,13 @@ namespace Orchard.Commands {
}
if (propertyInfo.PropertyType.IsAssignableFrom(typeof(bool))) {
bool boolValue;
// todo: might be better to throw here if TryParse returns false instead of silently using 'false', to catch types (e.g. 'ture')
Boolean.TryParse(commandSwitch.Value, out boolValue);
propertyInfo.SetValue(this, boolValue, null);
}
else if (propertyInfo.PropertyType.IsAssignableFrom(typeof(int))) {
int intValue;
// todo: might be better to throw here if TryParse returns false instead of silently using 0 value
Int32.TryParse(commandSwitch.Value, out intValue);
propertyInfo.SetValue(this, intValue, null);
}

View File

@@ -3,6 +3,7 @@ using System.Runtime.Serialization;
using Orchard.Localization;
namespace Orchard.Commands {
[Serializable]
public class OrchardCommandHostRetryException : OrchardCoreException {
public OrchardCommandHostRetryException(LocalizedString message)
: base(message) {

View File

@@ -3,6 +3,7 @@ using System.Data;
namespace Orchard.Data.Migration.Schema {
public static class SchemaUtils {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "System.Enum.TryParse<System.Data.DbType>(System.String,System.Boolean,System.Data.DbType@)")]
public static DbType ToDbType(Type type) {
DbType dbType;
switch ( System.Type.GetTypeCode(type) ) {

View File

@@ -58,7 +58,6 @@ namespace Orchard.Data {
using (var stream = _appDataFolder.CreateFile(pathName)) {
formatter.Serialize(stream, cache.Hash);
formatter.Serialize(stream, cache.Configuration);
stream.Close();
}
}
catch (Exception e) {

View File

@@ -45,6 +45,7 @@ namespace Orchard.Environment.Descriptor {
#region Implementation of IShellDescriptorCache
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "StringReader closed by XmlReader.")]
public ShellDescriptor Fetch(string name) {
VerifyCacheFile();
var text = _appDataFolder.ReadFile(DescriptorCacheFileName);
@@ -64,6 +65,7 @@ namespace Orchard.Environment.Descriptor {
return null;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "writer closed by xmlWriter.")]
public void Store(string name, ShellDescriptor descriptor) {
VerifyCacheFile();
var text = _appDataFolder.ReadFile(DescriptorCacheFileName);
@@ -101,6 +103,7 @@ namespace Orchard.Environment.Descriptor {
#endregion
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
private void VerifyCacheFile() {
if (!_appDataFolder.FileExists(DescriptorCacheFileName)) {
var writer = new StringWriter();

View File

@@ -81,6 +81,7 @@ namespace Orchard.Environment.Extensions.Compilers {
return unit;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
private string GetContents(string virtualPath) {
string contents;
using (var stream = _virtualPathProvider.OpenFile(virtualPath)) {

View File

@@ -92,6 +92,7 @@ namespace Orchard.FileSystems.AppData {
return Combine(AppDataPath, path);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
public void CreateFile(string path, string content) {
using (var stream = CreateFile(path)) {
using (var tw = new StreamWriter(stream)) {

View File

@@ -43,6 +43,7 @@ namespace Orchard.FileSystems.WebSite {
return ReadFile(virtualPath, false);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
public string ReadFile(string virtualPath, bool actualContent) {
if (!_virtualPathProvider.FileExists(virtualPath)) {
return null;

View File

@@ -41,7 +41,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>

View File

@@ -3,6 +3,7 @@ using System.Runtime.Serialization;
using Orchard.Localization;
namespace Orchard {
[Serializable]
public class OrchardCoreException : Exception {
private readonly LocalizedString _localizedMessage;

View File

@@ -3,6 +3,7 @@ using System.Runtime.Serialization;
using Orchard.Localization;
namespace Orchard {
[Serializable]
public class OrchardException : ApplicationException {
private readonly LocalizedString _localizedMessage;

View File

@@ -4,6 +4,7 @@ using Orchard.ContentManagement;
using Orchard.Localization;
namespace Orchard.Security {
[Serializable]
public class OrchardSecurityException : OrchardCoreException {
public OrchardSecurityException(LocalizedString message) : base(message) { }
public OrchardSecurityException(LocalizedString message, Exception innerException) : base(message, innerException) { }

View File

@@ -2,6 +2,7 @@
using System.Web.Security;
namespace Orchard.Security.Providers {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
public class OrchardRoleProvider : RoleProvider {
public override bool IsUserInRole(string username, string roleName) {
throw new NotImplementedException();

View File

@@ -11,10 +11,10 @@ namespace Orchard.UI {
// null == "before; "" == "0"
x = x == null
? "before"
: x.Trim() == "" ? "0" : x.Trim(':').TrimEnd('.'); // ':' is _sometimes_ used as a partition identifier
: x.Trim().Length == 0 ? "0" : x.Trim(':').TrimEnd('.'); // ':' is _sometimes_ used as a partition identifier
y = y == null
? "before"
: y.Trim() == "" ? "0" : y.Trim(':').TrimEnd('.');
: y.Trim().Length == 0 ? "0" : y.Trim(':').TrimEnd('.');
var xParts = x.Split(new[] { '.', ':' });
var yParts = y.Split(new[] { '.', ':' });

View File

@@ -11,7 +11,7 @@ namespace Orchard.Utility {
if (topMenuItem != null) {
var maxMenuItem = topMenuItem.Items.Where(PositionHasMojorNumber).OrderByDescending(mi => mi.Position, new FlatPositionComparer()).FirstOrDefault();
var positionParts = maxMenuItem.Position.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries).Where(s => s.Trim() != "");
var positionParts = maxMenuItem.Position.Split(new[] {'.'}, StringSplitOptions.RemoveEmptyEntries).Where(s => s.Trim().Length > 0);
if (positionParts.Count() > 0) {
int result;
if (int.TryParse(positionParts.ElementAt(0), out result)) {

View File

@@ -2,13 +2,10 @@
<RuleSet Name="Orchard Basic Correctness Rules" Description="These rules focus on logic errors and common mistakes made in the usage of framework APIs. Include this rule set to expand on the list of warnings reported by the minimum recommended rules." ToolsVersion="10.0">
<Include Path="minimumrecommendedrules.ruleset" Action="Default" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1008" Action="Warning" />
<Rule Id="CA1013" Action="Warning" />
<Rule Id="CA1033" Action="None" />
<Rule Id="CA1308" Action="Warning" />
<Rule Id="CA1806" Action="Warning" />
<Rule Id="CA1816" Action="Warning" />
<Rule Id="CA1819" Action="Warning" />
<Rule Id="CA1820" Action="Warning" />
<Rule Id="CA1903" Action="Warning" />
<Rule Id="CA2004" Action="Warning" />
@@ -22,6 +19,7 @@
<Rule Id="CA2121" Action="Warning" />
<Rule Id="CA2130" Action="Warning" />
<Rule Id="CA2205" Action="Warning" />
<Rule Id="CA2214" Action="None" />
<Rule Id="CA2215" Action="Warning" />
<Rule Id="CA2221" Action="Warning" />
<Rule Id="CA2222" Action="Warning" />

View File

@@ -4,7 +4,6 @@
<Rule Id="CA2100" Action="Warning" />
<Rule Id="CA2102" Action="Warning" />
<Rule Id="CA2103" Action="Warning" />
<Rule Id="CA2104" Action="Warning" />
<Rule Id="CA2105" Action="Warning" />
<Rule Id="CA2106" Action="Warning" />
<Rule Id="CA2107" Action="Warning" />

View File

@@ -42,7 +42,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@@ -41,7 +41,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>

View File

@@ -42,7 +42,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@@ -43,7 +43,7 @@
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>true</UseVSHostingProcess>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>..\..\OrchardSecurity.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>

View File

@@ -20,6 +20,7 @@ namespace PackageIndexReferenceImplementation.Controllers {
return new StreamResult(contentType, _mediaStorage.GetMedia(id + ":" + contentType));
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
public ActionResult PreviewTheme(string id, string contentType) {
var stream = _mediaStorage.GetMedia(id + ":" + contentType);
var package = Package.Open(stream, FileMode.Open, FileAccess.Read);

View File

@@ -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>