Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 268 additions & 0 deletions all.csv

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions v2/Generator.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
# Visual Studio Version 18
VisualStudioVersion = 18.4.11626.88 stable
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Generator", "Generator\Generator.csproj", "{48CA2DDA-C3D0-4D5F-9A05-8CEFEB777E61}"
EndProject
Expand All @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneratorData", "GeneratorD
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GV.Steps", "GV.Steps\GV.Steps.csproj", "{57236574-B2E4-4742-BDD3-0C72E2220676}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenLiveWriterPost", "OpenLiveWriterPost\OpenLiveWriterPost.csproj", "{DF7E2A72-9D51-4AC9-982D-5EDC36B5DA26}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +35,10 @@ Global
{57236574-B2E4-4742-BDD3-0C72E2220676}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57236574-B2E4-4742-BDD3-0C72E2220676}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57236574-B2E4-4742-BDD3-0C72E2220676}.Release|Any CPU.Build.0 = Release|Any CPU
{DF7E2A72-9D51-4AC9-982D-5EDC36B5DA26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF7E2A72-9D51-4AC9-982D-5EDC36B5DA26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF7E2A72-9D51-4AC9-982D-5EDC36B5DA26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF7E2A72-9D51-4AC9-982D-5EDC36B5DA26}.Release|Any CPU.Build.0 = Release|Any CPU
Comment on lines +38 to +41
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check platform configuration across solution and project files

echo "=== Solution platform configurations for OpenLiveWriterPost ==="
rg "DF7E2A72-9D51-4AC9-982D-5EDC36B5DA26" v2/Generator.sln -A 1

echo -e "\n=== Project PlatformTarget setting ==="
rg "PlatformTarget" v2/OpenLiveWriterPost/OpenLiveWriterPost.csproj

echo -e "\n=== Manifest processorArchitecture ==="
rg "processorArchitecture" v2/dlls/Writer/OpenLiveWriter.exe.manifest

Repository: ignatandrei/RSCG_Examples

Length of output: 862


Platform configuration mismatch between solution and project files.

The solution (v2/Generator.sln) maps the OpenLiveWriterPost project to Any CPU configuration, while the project file specifies <PlatformTarget>x86</PlatformTarget> and the manifest declares processorArchitecture="X86". This mismatch will cause build inconsistencies or runtime issues, particularly with the x86-specific OpenLiveWriter dependencies.

Resolve by either:

  1. Changing the solution platform configuration to x86, or
  2. Updating the project's PlatformTarget to AnyCPU (if compatible with x86-specific dependencies)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@v2/Generator.sln` around lines 38 - 41, The solution maps the
OpenLiveWriterPost project (GUID DF7E2A72-9D51-4AC9-982D-5EDC36B5DA26) to Any
CPU while the project declares <PlatformTarget>x86</PlatformTarget> and manifest
processorArchitecture="X86", causing a platform mismatch; fix by making the
platforms consistent: either change the solution configuration entry for that
project (the lines referencing
{DF7E2A72-9D51-4AC9-982D-5EDC36B5DA26}.Debug/Release|Any CPU.*) to use x86, or
update the project properties to use PlatformTarget AnyCPU and adjust the
manifest processorArchitecture accordingly if the x86-specific dependencies
allow it, then re-run a clean build to verify no runtime or dependency issues
remain.

EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 5 additions & 2 deletions v2/Generator/Generator.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -90,6 +92,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GeneratorData\GeneratorData.csproj" />
<ProjectReference Include="..\OpenLiveWriterPost\OpenLiveWriterPost.csproj" />
</ItemGroup>


Expand Down
2 changes: 2 additions & 0 deletions v2/Generator/MultiGeneratorV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,8 @@ private async Task<bool> WrotePost(Description it, string pathDocusaurus)
await File.WriteAllTextAsync(file, output);
Process.Start("notepad.exe", file);
//Console.WriteLine(output);
OpenLiveWriterPost.WritePost.GeneratePostFromHtml(it.Generator.Name ?? "", output);

await Task.Delay(100);
return true;
}
Expand Down
29 changes: 29 additions & 0 deletions v2/OpenLiveWriterPost/OpenLiveWriterPost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
<Reference Include="OpenLiveWriter.CoreServices">
<HintPath>..\dlls\Writer\OpenLiveWriter.CoreServices.dll</HintPath>
</Reference>
<Reference Include="OpenLiveWriter.Extensibility">
<HintPath>..\dlls\Writer\OpenLiveWriter.Extensibility.dll</HintPath>
</Reference>
<Reference Include="OpenLiveWriter.PostEditor">
<HintPath>..\dlls\Writer\OpenLiveWriter.PostEditor.dll</HintPath>
</Reference>
<Reference Include="OpenLiveWriter.Interop">
<HintPath>..\dlls\Writer\OpenLiveWriter.Interop.dll</HintPath>
<Private>true</Private>
</Reference>

</ItemGroup>

</Project>
76 changes: 76 additions & 0 deletions v2/OpenLiveWriterPost/OpenLiveWriterPostGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using OpenLiveWriter.CoreServices;
using OpenLiveWriter.Extensibility.BlogClient;
using OpenLiveWriter.PostEditor;
using System.Reflection;

namespace OpenLiveWriterPost;

internal class OpenLiveWriterPostGenerator
{


public static void SavePost(BlogPost post, string filePath)
{
SavePostAsStructuredStorage(post, filePath);
}

private static void SavePostAsStructuredStorage(BlogPost post, string filePath)
{
ApplicationEnvironment.Initialize(Assembly.GetExecutingAssembly(),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Windows Live\Writer"));

PostEditorFile.Initialize();

string? directoryPath = Path.GetDirectoryName(filePath);
if (string.IsNullOrEmpty(directoryPath))
{
directoryPath = Directory.GetCurrentDirectory();
}

DirectoryInfo targetDirectory = new DirectoryInfo(directoryPath);
string[] existingDrafts = Directory.GetFiles(targetDirectory.FullName, "*.wpost");

PostEditorFile pef = PostEditorFile.CreateNew(targetDirectory);
var bef = new BlogPostEditingContext(post.Id, post);
pef.SaveBlogPost(bef);

string createdDraftPath = FindCreatedDraftPath(targetDirectory.FullName, existingDrafts);
if (!string.Equals(createdDraftPath, filePath, StringComparison.OrdinalIgnoreCase))
{
if (File.Exists(filePath))
{
File.Delete(filePath);
}

File.Move(createdDraftPath, filePath);
}
}

private static string FindCreatedDraftPath(string directoryPath, string[] existingDrafts)
{
string[] currentDrafts = Directory.GetFiles(directoryPath, "*.wpost");

foreach (string currentDraft in currentDrafts)
{
bool existedBefore = false;
foreach (string existingDraft in existingDrafts)
{
if (string.Equals(currentDraft, existingDraft, StringComparison.OrdinalIgnoreCase))
{
existedBefore = true;
break;
}
}

if (!existedBefore)
{
return currentDraft;
}
}

throw new IOException($"Unable to determine the draft file created in '{directoryPath}'.");
}



}
76 changes: 76 additions & 0 deletions v2/OpenLiveWriterPost/WritePost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using OpenLiveWriter.Extensibility.BlogClient;
using OpenLiveWriter.Extensibility.ImageEditing;

namespace OpenLiveWriterPost;
public static class WritePost
{
public static void GeneratePostFromHtml(string name, string html)
{
var draftsFolder1 = GetOpenLiveWriterDraftsFolder();
var post1 = new BlogPost
{
Id = Guid.NewGuid().ToString("D"),
Title = name,
DatePublished = DateTime.Now.AddDays(10),
DatePublishedOverride = DateTime.Now.AddDays(10),
Contents = html,
//Categories = [ "Programming", "C#", "Blogging" ],
};
// Save the post
var safeTitle = SanitizeFileName(post1.Title);
var fileName1 = $"{safeTitle}.wpost";
var filePath1 = Path.Combine(draftsFolder1, fileName1);

if(File.Exists(filePath1)) File.Delete(filePath1);

Console.WriteLine("Creating hardcoded blog post...");

OpenLiveWriterPostGenerator.SavePost(post1, filePath1);
Comment on lines +25 to +29
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid deleting the existing draft before confirming save succeeds.

Line 25 deletes the existing .wpost first. If Line 29 fails, the old draft is lost.

Suggested fix
-        if(File.Exists(filePath1)) File.Delete(filePath1);
-
-        Console.WriteLine("Creating hardcoded blog post...");
-        
-        OpenLiveWriterPostGenerator.SavePost(post1, filePath1);
+        var backupPath = filePath1 + ".bak";
+        if (File.Exists(filePath1))
+            File.Copy(filePath1, backupPath, overwrite: true);
+
+        Console.WriteLine("Creating hardcoded blog post...");
+
+        try
+        {
+            OpenLiveWriterPostGenerator.SavePost(post1, filePath1);
+            if (File.Exists(backupPath)) File.Delete(backupPath);
+        }
+        catch
+        {
+            if (File.Exists(backupPath))
+                File.Move(backupPath, filePath1, overwrite: true);
+            throw;
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(File.Exists(filePath1)) File.Delete(filePath1);
Console.WriteLine("Creating hardcoded blog post...");
OpenLiveWriterPostGenerator.SavePost(post1, filePath1);
var backupPath = filePath1 + ".bak";
if (File.Exists(filePath1))
File.Copy(filePath1, backupPath, overwrite: true);
Console.WriteLine("Creating hardcoded blog post...");
try
{
OpenLiveWriterPostGenerator.SavePost(post1, filePath1);
if (File.Exists(backupPath)) File.Delete(backupPath);
}
catch
{
if (File.Exists(backupPath))
File.Move(backupPath, filePath1, overwrite: true);
throw;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@v2/OpenLiveWriterPost/WritePost.cs` around lines 25 - 29, The code currently
deletes the existing draft (File.Delete on filePath1) before calling
OpenLiveWriterPostGenerator.SavePost, risking data loss if SavePost throws;
instead, write the new content to a temporary file (e.g., filePath1 + ".tmp")
via OpenLiveWriterPostGenerator.SavePost(post1, tempPath), verify the save
succeeded, then atomically replace the original (use File.Replace or move/rename
with overwrite) from tempPath to filePath1 so the original is preserved on
failure; ensure exceptions from SavePost leave the original file intact and
clean up the temp file on success or failure.


}
static string SanitizeFileName(string? name)
{
var sanitizedName = (name ?? string.Empty).Trim();
foreach (var invalidChar in Path.GetInvalidFileNameChars())
{
sanitizedName = sanitizedName.Replace(invalidChar, '_');
}

return string.IsNullOrWhiteSpace(sanitizedName) ? "untitled" : sanitizedName;
}
static string GetOpenLiveWriterDraftsFolder()
{
// OpenLive Writer drafts are typically stored in:
// %USERPROFILE%\Documents\My Weblog Posts\Drafts
// or
// %LOCALAPPDATA%\OpenLiveWriter\Drafts

var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

// Try different possible locations for OpenLive Writer drafts
var possiblePaths = new[]
{
Path.Combine(documentsPath, "My Weblog Posts", "Drafts"),
Path.Combine(localAppData, "OpenLiveWriter", "Drafts"),
Path.Combine(userProfile, "Documents", "My Weblog Posts", "Drafts"),
Path.Combine(localAppData, "Open Live Writer", "Drafts")
};

foreach (var path in possiblePaths)
{
if (Directory.Exists(path))
{
Console.WriteLine($"Using existing OpenLive Writer drafts folder: {path}");
return path;
}
}

// If none exist, create the default one
var defaultPath = Path.Combine(documentsPath, "My Weblog Posts", "Drafts");
Console.WriteLine($"Creating OpenLive Writer drafts folder: {defaultPath}");
Directory.CreateDirectory(defaultPath);
return defaultPath;
}
}
Binary file added v2/dlls/Writer/ApprovalTests.dll
Binary file not shown.
31 changes: 31 additions & 0 deletions v2/dlls/Writer/ApprovalTests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added v2/dlls/Writer/ApprovalUtilities.Net45.dll
Binary file not shown.
8 changes: 8 additions & 0 deletions v2/dlls/Writer/ApprovalUtilities.Net45.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added v2/dlls/Writer/ApprovalUtilities.dll
Binary file not shown.
13 changes: 13 additions & 0 deletions v2/dlls/Writer/ApprovalUtilities.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added v2/dlls/Writer/BlogRunner.Core.dll
Binary file not shown.
Binary file added v2/dlls/Writer/BlogRunner.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions v2/dlls/Writer/BlogRunner.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Core" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.39.0.0" newVersion="1.39.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Google.Apis" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.39.0.0" newVersion="1.39.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Binary file added v2/dlls/Writer/BlogRunnerGui.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions v2/dlls/Writer/BlogRunnerGui.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Core" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.39.0.0" newVersion="1.39.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Google.Apis" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.39.0.0" newVersion="1.39.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Binary file added v2/dlls/Writer/BlogRunnerReporter.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions v2/dlls/Writer/BlogRunnerReporter.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
Binary file not shown.
Binary file not shown.
Binary file added v2/dlls/Writer/DeltaCompressionDotNet.dll
Binary file not shown.
Binary file not shown.
Binary file added v2/dlls/Writer/Google.Apis.Auth.dll
Binary file not shown.
Loading
Loading