How to set up an automatic versioning on TortoiseSVN? - c#

I am trying to set up an auto-versioning update on TortoiseSVN for a project I'm working on. It's very straightforward; the code is supposed to pull the SVN revision and display the date & location whenever anyone does a checkout/update from the repo.
Below I have a template class
public static class SvnRevision
{
/// <summary>
/// SVN repo revision
/// </summary>
public const string REVISION = "$WCREV$";
/// <summary>
/// SVN repo location
/// </summary>
public const string REPOSITORY_URL = #"$WCURL$";
/// <summary>
/// SVN repo date
/// </summary>
public const string REPOSITORY_DATE = "$WCDATE$";
}
I want to know the background steps necessary to get this program to work. Appreciate if anyone could provide a walk through or tutorial. I am trying to do this on Visual Studio 2022.
I made commits using this class to SVN without any luck, a search indicates that I need to set up versioning and provide some kind of source/destination files that I don't know how to do. Below is a link I've referenced.
https://docs.huihoo.com/tortoisesvn/1.5.7-en/tsvn-subwcrev-keywords.html

Before selecting The Right Thing (tm) for your task and|or using SubWCRev (which you try to use, according to used subwcrev-specific keywords) you have to know some things
Best (and, really, single correct place) for reading updated, relevant to latest release docs about SubWCRev is TortoiseSVN website (SubWCRev is part of TortoiseSVN distribution and is not of pure SVN per se)
"...whenever anyone does a checkout/update from the repo" such person with WC of your repo have more natural way to know, which revision he|she got and whence: ordinary svn info tells it, instead of reading your code or compiling it in order to see message-box with collected data
Contrary to SVN-keywords, which work from a box (when inserted into files) and updated automagically on the fly, subwcrev's keywords have to have "release" stage (read docs): you insert keywords in template-file, which, after processing by SubWCRev, will produce new file, in which template-placeholders are replaced by data, actual only for this moment and not updated automatically after WC-changes (you must to refresh files from templates again)
In your case you can
move public static class SvnRevision into somename.cs.tpl with all needed keywords
Before all other steps in your compile-chain add call of SubWCRev, smth.like SubWCRev.exe path\to\WC somename.cs.tpl somename.cs
In you code use references to somename.cs, which also have to be in svn-ignore and not versioned, while template have to be versioned
HTH

Thanks for all the help everyone. Likely my line of questioning was not clear or I worked it wrong, but the problem was that I needed to set a command line as a prebuild event so that the SVN keywords would update.
Prebuild event command line: "C:\Program Files\TortoiseSVN\bin\SubWCRev.exe" "$(ProjectDir)." "$(ProjectDir)SvnRevision_Template.cs" "$(ProjectDir)SvnRevision.cs"

Related

Why can't I see my <example>s and <code>s from Intellisense? using C# and Visual Studio 2017-2019

I am currently using Visual Studio 2019 to write a WPF/C# application.
After writing a new method I decided to add some examples for better usage.
But my example won't show up in the Intellisense popup.
I've tried the following code:
/// <summary>...</summary>
/// <param name="path">...</param>
/// <param name="action">...</param>
/// <example>
/// Use this method like this:
/// <code>
/// MyMethod("C:\\someFile.txt", s => File.Copy(s, "C:\\someFile (copy).txt"));
/// </code>
/// </example>
public static void MyMethod(string path, Action<string> action)
{
// some code ...
}
I expected my example to show up on the Intellisense popup that pops up when calling from another file.
What happens is just the summary shows up without my examples..
It is simple - because it works so. And never worked as you expected.
Your XML comments is fine but Visual Studio shows only <summary> section (Short discription of class \ method or property) for quick familiarize with class \ method or property you are going to use.
XML comments can be very big, litterally nothing limits it size. Imagine what size shoud be tooltip to show you big comments?
So if you or other developer use Visual Studio and tooltip with <summary> does not give you enough information - just simply go to decloration with F12 and read full comment OR you can show declaration right in current section with ALT + F12
Not shure but i think it can be some extensions for showing tooltip as you want

Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) in VS Extensibility walkthrough

I am using the Walkthrough: Part 1 - Creating a Basic Project System exactly as written from the website http://msdn.microsoft.com/en-us/library/cc512961.aspx and the Managed Package Framework for Projects exactly as downloaded from http://mpfproj11.codeplex.com/. I have tested the walkthrough on multiple development machines in Visual Studio 2013. I also tested this in Visual Studio 2010 and 2012 using their respective SDK’s. The same issues to follow presented themselves in each of the tests.
Issue: I am receiving the exception- An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) in the ProjectNode class method:
private void SetProjectGuidFromProjectFile()
{
string projectGuid = this.GetProjectProperty(ProjectFileConstants.ProjectGuid);
if (String.IsNullOrEmpty(projectGuid))
{
this.projectIdGuid = Guid.NewGuid();
}
else
{
Guid guid = new Guid(projectGuid);
if (guid != this.projectIdGuid)
{
this.projectIdGuid = guid;
}
}
}
On the line Guid guid = new Guid(projectGuid);
projectGuid is returning the string “$guid1$” which is from <ProjectGuid>$guid1$</ProjectGuid> in SimpleProject.myproj.
Break points in the Load method of the ProjectNode class shows that
this.projectIdGuid = Guid.NewGuid();
returns a new guid such as {6d4b8668-51ca-40eb-b013-9e7f96b82b68}.
In the Reload method of the ProjectNode class the method this.SetProjectGuidFromProjectFile() is fired and then the exeption is thrown as shown above. If I take out <ProjectGuid>$guid1$</ProjectGuid> in SimpleProject.myproj, I get through to the application without exception but you will have no guid associated with the application and will receive an error if an attempt to access the properties page of the newly created application. .myproj may not be registering correctly? I have spent a week researching this topic through various blogs and forums.
The problem comes from the fact the MPF (which is a serious crappy piece of code - unfortunately, it's the only full-blown sample available) implements a custom template parameter replacement process (a Visual Studio-specific process described here: http://msdn.microsoft.com/en-us/library/eehb4faa.aspx) that only supports replacement for all project (sub) items, but not for the project item itself. So, you cannot use $guid1$ or any other $thingy$ in the xxxx.myproj file.
As you found out, the easiest way is to just remove this $guid1$ parameter, and let it blank, as the MPF does support a blank one:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<ProjectGuid></ProjectGuid>
...
</PropertyGroup>
...
</Project>
Now, contrary to your belief :) this works fine. This sets the ProjectIDGuid ProjectNode's property.
The property page you're also after is a totally different beast. To simplify, Visual Studio will query your hierarchy for the __VSHPROPID2.VSHPROPID_PropertyPagesCLSIDList property. By default, the MPF implements it like this:
/// <summary>
/// List of Guids of the config independent property pages. It is called by the GetProperty for VSHPROPID_PropertyPagesCLSIDList property.
/// </summary>
/// <returns></returns>
protected virtual Guid[] GetConfigurationIndependentPropertyPages()
{
return new Guid[] { Guid.Empty };
}
Guid.Empty is a poor choice (they could just send an empty array), because it will raise the following error which is hard to diagnose with the standard empty guid we don't known where it comes from:
So, what you need to do is override GetConfigurationIndependentPropertyPages and give it another Guid that correspond to a class that derive from SettingsPage, etc. but that's another story.

The call is ambiguous between the following methods: Identical.NameSpace.InitializeComponent() and Identical.NameSpace.InitializeComponent()

Ok, I suspect this might be a Visual Studio thing, but there must be some reason for this. I created from the list of default items a ListBox (Right Click on project, or folder in project -> Add -> New Item -> Xaml ListBox). Immediately I get a red squiggly line with the error:
"Error 2 The call is ambiguous between the following methods or
properties: 'Identical.NameSpace.ListBox1.InitializeComponent()' and
'Identical.NameSpace.ListBox1.InitializeComponent()' C:\Documents and
Settings\ouflak\My Documents\Visual Studio
2010\Projects\Identical\NameSpace\ListBox1.xaml.cs 27"
All of the code in question is auto-generated and the reason for the error is because of a conflict between two auto-generated files: ListBox1.g.cs and ListBox1.designer.cs where public void InitializeComponent() is declared in both. Naturally the code cannot compile under this circumstance. It is simple enough to just delete the ListBox1.designer.cs and move on I suppose. But my question: Why is this code auto-generated with this error? I would expect anything auto-generated to be able to build and compile without having to touch the project or any code. For just about every other toobox item that you can add, this is the case. So why generate this code with the built-in error? Are we supposed to find some way to make this work? Is this code merely a suggestion and it is up to the IDE user/developer to hammer out the details?
Here is the generated code:
ListBox1.xaml:
< ?xml version="1.0" encoding="utf-8" ? >
< ListBox
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:xc="http://ns.neurospeech.com/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
x:Class="Identical.NameSpace.ListBox1"
>
<sys:String>Item 1</sys:String>
<sys:String>Item 2</sys:String>
<sys:String>Item 3</sys:String>
< /ListBox>
ListBox1.g.cs:
namespace Identical.Namespace
{
/// <summary>
/// ListBox1
/// </summary>
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public partial class ListBox1 : System.Windows.Controls.ListBox, System.Windows.Markup.IComponentConnector {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/MyProject;component/namespace/listbox1.xaml", System.UriKind.Relative);
#line 1 "..\..\..\namespace\ListBox1.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
this._contentLoaded = true;
}
}
}
ListBox1.designer.cs:
namespace Identical.NameSpace
{
using System;
public partial class ListBox1 : System.Windows.Controls.ListBox
{
private void InitializeComponent()
{
// Pre Statements...
string string1 = "Item 1";
string string2 = "Item 2";
string string3 = "Item 3";
// Statements...
this.BeginInit();
this.Items.Add(string1);
this.Items.Add(string2);
this.Items.Add(string3);
this.EndInit();
// Post Statements...
}
}
}
and lastly the ListBox1.xaml.cs (only modified to prevent XML documentation and Stylecop warnings):
namespace Identical.NameSpace
{
/// <summary>
/// ListBox1 class
/// </summary>
public partial class ListBox1 : ListBox
{
/// <summary>
/// Initializes a new instance of the ListBox1 class
/// </summary>
public ListBox1()
{
this.InitializeComponent();
}
}
}
That's it. This is the code entirely in its virgin auto-generated state with the exception of the comments I put into the xaml.cs file.
I've searched this site and the internet a bit, but no one seems to have explained this behavior. I will probably just delete the designer.cs code and move on. But if anybody knows why this is here in the first place, or if it is indeed a bug in Visual Studio 2010 professional, I'd really like to know.
I had this issue when copying my XAML between controls. I just had to change my x:Class="mynamespace" where mynamespace is the proper namespace for your project. Recompiled and all went back to normal.
It appears that you have declared the InitializeComponent method in two places in your class, probably one in each partial class. Try searching in all files for InitializeComponent in Visual Studio and I'm guessing that the results will list two places where it is declared. Delete one and the error will disappear.
UPDATE >>>
I'm not sure what kind of answer you're expecting here... clearly, if you didn't add one of those InitializeComponent method definitions, then visual Studio has a bug. I very much doubt that there can be any kind of logical reason for this except that it's a bug.
UPDATE 2 >>>
I had a look on the Microsoft Connect website for any existing reported bugs like this but couldn't find any... I've left the link here if you do want to report it to them.
My problem was the project that was giving me the ambiguous call had a reference to its own dll. This was causing the method to be referenced from the dll as well as in the actual project. Once i removed the dll from the references the ambiguous call error went away.
Can happen if you are not alert and careful about how you use Resharper.
This happened to me when a I allowed Resharper to auto-import references while I was coding.
So having mistyped initially, then edited the code I was working on, I did not check what it had imported. After running into the same issue, I realised that there was a self-reference in the same library. So there were double implementations of the method in question.
Both classes are partial, meaning they share each others non private fields & methods.
Your ListBox1 does have two InitializeComponent (shared) methods. Changing the namespace of either ListBox1 will resolve this error.
I think InitializeComponent() is declared in two different locations in the same class.
Try to find both class definitions using CTR+F and then resolve solve the ambiguity.
I ran into this issue, with a user control and an associated style. I think I had tried to move some logic into the style class but it didn't work, so I undid it, but apparently something got left behind.
It was also complaining about the _contentLoaded variable, so I tried deleting the one that was there, and the error went away, and was not replaced with another error. I then hit F12 to go to _contentLoaded's definition and found that it was in the *.g file for the style class. Though the file was named after the style, the class inside was named after the user control.
I deleted the bin and obj folders to resolve it.
I managed to resolve this by looking inside the .csproj file with a text editor and looking for the name of the Table Adapter XSD file. I found two references to it one with a different alias name hence why I was getting this error message.
I have just had and resolved this exact thing..
It happened at some point during or after I duplicated a form, in a WinForms program, then renamed it to blah_Copy.
The main cs file and the designer cs file, are both partial classes. So if a method is defined in both and it has the same name and parameters (or same name and same no paramters) , / same signature then it will clash.
In my case they both, both Initialize() { .. } definitions, had identical bodies so I easily just removed one.
Also let's say the method is Initialize() (it was in my case). If you go to call itself, then hit F12 it will go to one of((or perhaps even at least one), of the definitions.
I fixed this issue by cleaning up the bin and obj folders. You can try to remove these two folders and then rebuild the solution.
I had the same problem after changing a bunch of files at once, here's how I fixed it:
Find the solution in Solution Explorer (View -> Solution Explorer)
Right-click on the solution and click "Clean Solution"
.. and that's it! Visual Studio can be weird sometimes..
After copy and paste, as well as renaming the new class in code, also open the designer and change the name in the first line of the XAML. Build the project. Fixed!

SharedResourceDictionary: edit resource in Blend

To optimize my application, I create a SharedResourceDictionary. With this, I save about 250 mb of memory at run-time, so it works well.
My problem is in design-time, in Blend 4, I have no more access to my resource. To modify a template (witch is in my resource file), I usually right click on my control and I choose Edit Template --> Edit Current, like in this image:
I need to modify my template that way, it's 100x faster then to go in my resource file and find the good one... I have A LOT of resources...
My SharedResourceDictionary is implemented like this (found on the web):
public class SharedResourceDictionary : ResourceDictionary
{
/// <summary>
/// Internal cache of loaded dictionaries
/// </summary>
public static Dictionary<Uri, ResourceDictionary> _sharedDictionaries =
new Dictionary<Uri, ResourceDictionary>();
/// <summary>
/// Local member of the source uri
/// </summary>
private Uri _sourceUri;
/// <summary>
/// Gets or sets the uniform resource identifier (URI) to load resources from.
/// </summary>
public new Uri Source
{
get
{
if (IsInDesignMode)
return base.Source;
return _sourceUri;
}
set
{
_sourceUri = value;
if (!_sharedDictionaries.ContainsKey(value))
{
// If the dictionary is not yet loaded, load it by setting
// the source of the base class
base.Source = value;
// add it to the cache
_sharedDictionaries.Add(value, this);
}
else
{
// If the dictionary is already loaded, get it from the cache
MergedDictionaries.Add(_sharedDictionaries[value]);
}
}
}
/// <summary>
/// Check if we are in Blend to prevent error
/// </summary>
public bool IsInDesignMode
{
get
{
return
(bool)
DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty,
typeof(DependencyObject)).Metadata.DefaultValue;
}
}
}
Someone have an idea if there is a solution for this? I really want to keep this shared dictionary due to the memory improvement, but I also want to modify my resource easily...
Any clue will be appreciated. Thank you.
EDIT:
Doing this (SharedResourceDictionary), I also have an issue with static resource:
Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.
And when I change them to dynamic resource it works, or if I change the SharedResourceDictionary by a simple ResourceDictionary it also works. The project can compile but I cannot edit the resource without a modification as I said.
Are you compiling for .NET 4?
You might be hitting the bug where it fails to scan your ResourceDictionaries properly.
There's talk that you have to add your ResourceDictionaries at the the App.xaml level (in Application.Resources) level, and add a dummy default style.
This might not work for you as you seem to be adding your resources in your control.
http://blogs.windowsclient.net/rob_relyea/archive/2010/04/26/my-staticresource-reference-worked-differently-with-wpf-4-rc-than-it-does-with-wpf-4-rtm.aspx
Adding a Merged Dictionary to a Merged Dictionary
Trouble referencing a Resource Dictionary that contains a Merged Dictionary
http://connect.microsoft.com/VisualStudio/feedback/details/553528/defaultstylekey-style-not-found-in-inner-mergeddictionaries
Actually it is problematic to use this feature. =(
Maybe in the future things will get better, do not know if will help, but you can try a different implementation:
WPF SharedResourceDictionary
(but do not guarantee it will work)
I gave up using the SharedResourceDictionary because of problems at design time, only when the project is 100% completed I'll be back to use.

The type 'InversionOfControl.IOC' exists in both 'InversionOfControl.dll' and 'InversionOfControl.dll'

I have a project called InversionOfControl. That project has a class called IOC. It looks like this:
/// <summary>
/// This class is used to expose the unity container to the application.
/// </summary>
public class IOC
{
/// <summary>
/// The actual unity container for the app.
/// </summary>
public static IUnityContainer Container { get; set; }
}
All my projects that need to resolve unity injections have a reference to this class. Lately I have started getting this error:
Value cannot be null.
Parameter name: container
on normal resolves:
ITransmitModel transmitModel = IOC.Container.Resolve<ITransmitModel>();
When I try to inspect IOC.Container, the value in the watch window is:
The type 'InversionOfControl.IOC' exists in both 'InversionOfControl.dll' and 'InversionOfControl.dll'
I have looked in my output folder and there is only one InversionOfControl.dll file. (I even cleaned my solution and double checked the folder was empty. I then rebuilt and checked again that there is only one.)
Why does it think there are two dlls called InversionOfControl.dll?
A way to check what module is loaded at run-time is "Debug->Windows->Modules" and check out where the DLL in question is loaded from. Make sure you are not loading 2 assemblies with different versions.
As a next step I would do search for all files with this name to see if there are suspicious copies ("cd /d c:\ & dir /s /b InversionOfControl.dll").

Categories

Resources