Remove DOTNET4 constant - it was used to support .NET 3.5 which is no longer built. See #174

This commit is contained in:
Christoph Wille 2019-06-10 10:42:40 +02:00
Родитель 78ea8e166b
Коммит c62843cc6a
11 изменённых файлов: 14 добавлений и 111 удалений

Просмотреть файл

@ -4,7 +4,7 @@
<TargetFrameworks>netcoreapp3.0;net40;net45</TargetFrameworks>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.snk</AssemblyOriginatorKeyFile>
<RootNamespace>AvalonEdit.Sample</RootNamespace>
@ -14,13 +14,13 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System.Windows.Forms" />

Просмотреть файл

@ -56,9 +56,9 @@ namespace ICSharpCode.AvalonEdit.Sample
InitializeComponent();
#if DOTNET4
this.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
#endif
propertyGridComboBox.SelectedIndex = 2;
//textEditor.TextArea.SelectionBorder = null;

Просмотреть файл

@ -4,7 +4,7 @@
<TargetFrameworks>net40;net45</TargetFrameworks>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.snk</AssemblyOriginatorKeyFile>
<Company>ic#code</Company>
@ -13,13 +13,13 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.11.0" />

Просмотреть файл

@ -1045,11 +1045,9 @@ namespace ICSharpCode.AvalonEdit.Editing
this.MouseEnter += delegate { ShowMouseCursor(); };
this.MouseLeave += delegate { ShowMouseCursor(); };
this.PreviewMouseMove += delegate { ShowMouseCursor(); };
#if DOTNET4
this.TouchEnter += delegate { ShowMouseCursor(); };
this.TouchLeave += delegate { ShowMouseCursor(); };
this.PreviewTouchMove += delegate { ShowMouseCursor(); };
#endif
}
void ShowMouseCursor()

Просмотреть файл

@ -155,11 +155,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
/// <summary>
/// Serializes this HighlightingColor instance.
/// </summary>
#if DOTNET4
[System.Security.SecurityCritical]
#else
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
#endif
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)

Просмотреть файл

@ -18,11 +18,7 @@
using System;
using System.IO;
#if DOTNET4
using System.Net;
#else
using System.Web;
#endif
namespace ICSharpCode.AvalonEdit.Highlighting
{
@ -64,11 +60,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (color == null)
throw new ArgumentNullException("color");
writer.Write(" style=\"");
#if DOTNET4
WebUtility.HtmlEncode(color.ToCss(), writer);
#else
HttpUtility.HtmlEncode(color.ToCss(), writer);
#endif
writer.Write('"');
}

Просмотреть файл

@ -19,11 +19,7 @@
using System;
using System.Collections.Generic;
using System.IO;
#if DOTNET4
using System.Net;
#else
using System.Web;
#endif
using System.Text;
using System.Windows;
using System.Windows.Media;
@ -136,11 +132,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
needIndentation = true;
break;
default:
#if DOTNET4
WebUtility.HtmlEncode(c.ToString(), htmlWriter);
#else
HttpUtility.HtmlEncode(c.ToString(), htmlWriter);
#endif
break;
}
// If we just handled a space by setting hasSpace = true,
@ -181,11 +173,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
if (value.Length == 0)
return;
WriteIndentationAndSpace();
#if DOTNET4
WebUtility.HtmlEncode(value, htmlWriter);
#else
HttpUtility.HtmlEncode(value, htmlWriter);
#endif
}
/// <inheritdoc/>
@ -256,11 +244,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting
public override void BeginHyperlinkSpan(Uri uri)
{
WriteIndentationAndSpace();
#if DOTNET4
string link = WebUtility.HtmlEncode(uri.ToString());
#else
string link = HttpUtility.HtmlEncode(uri.ToString());
#endif
htmlWriter.Write("<a href=\"" + link + "\">");
endTagStack.Push("</a>");
}

Просмотреть файл

@ -93,11 +93,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
/// <summary>
/// Serializes this XshdColor instance.
/// </summary>
#if DOTNET4
[System.Security.SecurityCritical]
#else
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
#endif
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)

Просмотреть файл

@ -4,7 +4,7 @@
<TargetFrameworks>netcoreapp3.0;net40;net45</TargetFrameworks>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>ICSharpCode.AvalonEdit.snk</AssemblyOriginatorKeyFile>
<DocumentationFile>ICSharpCode.AvalonEdit.xml</DocumentationFile>
@ -30,13 +30,13 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<DefineConstants>TRACE;DOTNET4</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System.Windows.Forms" />

Просмотреть файл

@ -77,12 +77,6 @@ namespace ICSharpCode.AvalonEdit
SetCurrentValue(DocumentProperty, new TextDocument());
}
#if !DOTNET4
void SetCurrentValue(DependencyProperty property, object value)
{
SetValue(property, value);
}
#endif
#endregion
/// <inheritdoc/>

Просмотреть файл

@ -31,19 +31,6 @@ namespace ICSharpCode.AvalonEdit.Utils
/// </summary>
static class TextFormatterFactory
{
#if !DOTNET4
readonly static DependencyProperty TextFormattingModeProperty;
static TextFormatterFactory()
{
Assembly presentationFramework = typeof(FrameworkElement).Assembly;
Type textOptionsType = presentationFramework.GetType("System.Windows.Media.TextOptions", false);
if (textOptionsType != null) {
TextFormattingModeProperty = textOptionsType.GetField("TextFormattingModeProperty").GetValue(null) as DependencyProperty;
}
}
#endif
/// <summary>
/// Creates a <see cref="TextFormatter"/> using the formatting mode used by the specified owner object.
/// </summary>
@ -51,21 +38,7 @@ namespace ICSharpCode.AvalonEdit.Utils
{
if (owner == null)
throw new ArgumentNullException("owner");
#if DOTNET4
return TextFormatter.Create(TextOptions.GetTextFormattingMode(owner));
#else
if (TextFormattingModeProperty != null) {
object formattingMode = owner.GetValue(TextFormattingModeProperty);
return (TextFormatter)typeof(TextFormatter).InvokeMember(
"Create",
BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static,
null, null,
new object[] { formattingMode },
CultureInfo.InvariantCulture);
} else {
return TextFormatter.Create();
}
#endif
}
/// <summary>
@ -74,11 +47,7 @@ namespace ICSharpCode.AvalonEdit.Utils
/// </summary>
public static bool PropertyChangeAffectsTextFormatter(DependencyProperty dp)
{
#if DOTNET4
return dp == TextOptions.TextFormattingModeProperty;
#else
return dp == TextFormattingModeProperty && TextFormattingModeProperty != null;
#endif
}
/// <summary>
@ -102,7 +71,6 @@ namespace ICSharpCode.AvalonEdit.Utils
emSize = TextBlock.GetFontSize(element);
if (foreground == null)
foreground = TextBlock.GetForeground(element);
#if DOTNET4
return new FormattedText(
text,
CultureInfo.CurrentCulture,
@ -113,31 +81,6 @@ namespace ICSharpCode.AvalonEdit.Utils
null,
TextOptions.GetTextFormattingMode(element)
);
#else
if (TextFormattingModeProperty != null) {
object formattingMode = element.GetValue(TextFormattingModeProperty);
return (FormattedText)Activator.CreateInstance(
typeof(FormattedText),
text,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
typeface,
emSize,
foreground,
null,
formattingMode
);
} else {
return new FormattedText(
text,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
typeface,
emSize.Value,
foreground
);
}
#endif
}
}
}