Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish mdoc net6 artifact #652

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ prepare:
clean:
dotnet build -v:n apidoctools.sln /t:clean /p:Configuration=$(CONFIGURATION)
rm -rf bin/$(CONFIGURATION)
rm -rf bin/$(CONFIGURATION)-net6.0

check: build check-monodoc check-mdoc

Expand Down
2 changes: 1 addition & 1 deletion Mdoc-ReleaseCheckCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pr:

# Variable 'needRunReleaseMdoc' was defined in the Variables tab
# Variable 'params' was defined in the Variables tab
# Agent Queue 'Azure Pipelines' was used with unrecognized Agent Specification, vmImage property must be specified to determine image - https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software
# Agent Queue 'Azure Pipelines' was used with unrecognized Agent Specification, vmImage property must be specified to determine image - https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#software
variables:
solution: 'apidoctools.sln'
buildConfiguration: 'Release'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `mdoc`

This repository contains the source for the .NET API Reference toolchain ([used
by docs.microsoft.com](https://docs.microsoft.com/en-us/teamblog/announcing-unified-dotnet-experience-on-docs#built-with-open-source-in-mind))
by learn.microsoft.com](https://learn.microsoft.com/en-us/teamblog/announcing-unified-dotnet-experience-on-docs#built-with-open-source-in-mind))

## Contribution Guide

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.lgtm.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core

pr: none
trigger: none
Expand Down
10 changes: 5 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- '*'
Expand All @@ -11,7 +11,7 @@ name: $(SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.r)
variables:
solution: 'apidoctools.sln'
buildConfiguration: 'Release'
mdocPath: 'bin/$(buildConfiguration)'
mdocPath: 'bin/$(buildConfiguration)-net6.0/win-x64'

stages:
- stage: SDLCheck
Expand Down Expand Up @@ -120,15 +120,15 @@ stages:
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
ConnectedServiceName: 'CodeSigning-APEX'
FolderPath: '$(mdocPath)'
FolderPath: 'bin'
UseMinimatch: true
signConfigType: inlineSignParams
SessionTimeout: '60'
MaxConcurrency: '100'
MaxRetryAttempts: '5'
Pattern: |
*.dll
*.exe
**\*.dll
**\*.exe
inlineOperation: |
[
{
Expand Down
166 changes: 83 additions & 83 deletions mdoc/Mono.Documentation/Util/AttachedEntitiesHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
Expand Down Expand Up @@ -55,7 +55,7 @@ private static IEnumerable<AttachedEventReference> GetAttachedEvents(TypeDefinit

private static bool IsAttachedEvent(FieldDefinition field, Dictionary<string, IEnumerable<MethodDefinition>> methods)
{
// https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/attached-events-overview
// https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/attached-events-overview
if (!field.Name.EndsWith(EventConst))
return false;
var addMethodName = $"Add{GetEventName(field.Name)}Handler";
Expand Down Expand Up @@ -92,11 +92,11 @@ private static bool AreAttachedEventMethodParameters(Collection<ParameterDefinit
return false;
return
// The first parameter is DependencyObject
(IsAssignableTo(parameters[0].ParameterType, Consts.DependencyObjectFullName) ||
IsAssignableTo(parameters[0].ParameterType, Consts.DependencyObjectFullNameWinRT) ||
IsAssignableTo(parameters[0].ParameterType, Consts.DependencyObjectFullNameWinUI))
// The second parameter is the handler to add/remove
(IsAssignableTo(parameters[0].ParameterType, Consts.DependencyObjectFullName) ||
IsAssignableTo(parameters[0].ParameterType, Consts.DependencyObjectFullNameWinRT) ||
IsAssignableTo(parameters[0].ParameterType, Consts.DependencyObjectFullNameWinUI))

// The second parameter is the handler to add/remove
&& IsAttachedEventHandler(parameters[1].ParameterType);
}

Expand All @@ -119,18 +119,18 @@ private static IEnumerable<AttachedPropertyReference> GetAttachedProperties(Type
yield return new AttachedPropertyReference(field);
}

foreach (var property in type.Properties.Where(t => t.PropertyType.FullName == Consts.DependencyPropertyFullName
|| t.PropertyType.FullName == Consts.DependencyPropertyFullNameWindowsXaml
|| t.PropertyType.FullName == Consts.DependencyPropertyFullNameMicrosoftXaml))
{
if (IsAttachedProperty(property, methods))
yield return new AttachedPropertyReference(property);
foreach (var property in type.Properties.Where(t => t.PropertyType.FullName == Consts.DependencyPropertyFullName
|| t.PropertyType.FullName == Consts.DependencyPropertyFullNameWindowsXaml
|| t.PropertyType.FullName == Consts.DependencyPropertyFullNameMicrosoftXaml))
{
if (IsAttachedProperty(property, methods))
yield return new AttachedPropertyReference(property);
}
}

private static bool IsAttachedProperty(FieldDefinition field, Dictionary<string, IEnumerable<MethodDefinition>> methods)
{
// https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/attached-properties-overview
// https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/attached-properties-overview
// https://github.com/mono/api-doc-tools/issues/63#issuecomment-328995418
if (!field.Name.EndsWith(PropertyConst, StringComparison.Ordinal))
return false;
Expand All @@ -155,30 +155,30 @@ private static bool IsAttachedProperty(FieldDefinition field, Dictionary<string,
&& ((methods.ContainsKey(getMethodName) && methods[getMethodName].Any(IsAttachedPropertyGetMethod))
|| (methods.ContainsKey(setMethodName) && methods[setMethodName].Any(IsAttachedPropertySetMethod)));

}
}

private static bool IsAttachedProperty(PropertyDefinition property, Dictionary<string, IEnumerable<MethodDefinition>> methods)
{
{

if (!property.Name.EndsWith(PropertyConst, StringComparison.Ordinal))
return false;
var propertyName = GetPropertyName(property.Name);
var propertyName = GetPropertyName(property.Name);
var getMethodName = $"Get{propertyName}";
var setMethodName = $"Set{propertyName}";

var hasExistingProperty = property?.DeclaringType?.Properties.Any(p => p.Name.Equals(propertyName, StringComparison.Ordinal) && GetCheckVisible(p.Resolve()));
var hasExistingField = property?.DeclaringType?.Fields.Any(f => f.Name.Equals(propertyName, StringComparison.Ordinal) && GetCheckVisible(f.Resolve()));

return !hasExistingProperty.IsTrue() && !hasExistingField.IsTrue() &&
// Class X has a static field of type DependencyProperty [Name]Property
(property.PropertyType.FullName == Consts.DependencyPropertyFullName || property.PropertyType.FullName == Consts.DependencyPropertyFullNameWindowsXaml
|| property.PropertyType.FullName == Consts.DependencyPropertyFullNameMicrosoftXaml)
// Class X also has static methods with the following names: Get[Name] or Set[Name]
return !hasExistingProperty.IsTrue() && !hasExistingField.IsTrue() &&
// Class X has a static field of type DependencyProperty [Name]Property
(property.PropertyType.FullName == Consts.DependencyPropertyFullName || property.PropertyType.FullName == Consts.DependencyPropertyFullNameWindowsXaml
|| property.PropertyType.FullName == Consts.DependencyPropertyFullNameMicrosoftXaml)


// Class X also has static methods with the following names: Get[Name] or Set[Name]
&& ((methods.ContainsKey(getMethodName) && methods[getMethodName].Any(IsAttachedPropertyGetMethod))
|| (methods.ContainsKey(setMethodName) && methods[setMethodName].Any(IsAttachedPropertySetMethod)));
|| (methods.ContainsKey(setMethodName) && methods[setMethodName].Any(IsAttachedPropertySetMethod)));

}

private static bool IsAttachedPropertyGetMethod(MethodDefinition method)
Expand All @@ -190,7 +190,7 @@ private static bool IsAttachedPropertyGetMethod(MethodDefinition method)

// The Get method takes one argument of type DependencyObject(or something IsAssignableTo(DependencyObject),
&& (IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullName) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullNameWinRT) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullNameWinRT) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullNameWinUI));
}

Expand All @@ -200,15 +200,15 @@ private static bool IsAttachedPropertySetMethod(MethodDefinition method)

// The first has type DependencyObject(or IsAssignableTo…),
&& (IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullName) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullNameWinRT) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullNameWinUI) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullNameWinRT) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyObjectFullNameWinUI) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyPropertyFullNameIInputElement) ||
IsAssignableTo(method.Parameters[0].ParameterType, Consts.DependencyPropertyFullNameObject))
// the second has type dp.PropertyType (or IsAssignableTo…).
// && IsAssignableTo(method.Parameters[1].ParameterType, "")
// It returns void.

// the second has type dp.PropertyType (or IsAssignableTo…).
// && IsAssignableTo(method.Parameters[1].ParameterType, "")

// It returns void.
&& method.ReturnType.FullName == Consts.VoidFullName;
}
#endregion
Expand All @@ -222,58 +222,58 @@ private static bool IsAssignableTo(TypeReference type, string targetTypeName)
return type.FullName == targetTypeName;

return type.FullName == targetTypeName || IsAssignableTo(typeDefenition.BaseType, targetTypeName);
}
private static bool GetCheckVisible(IMemberDefinition member)
{
if (member == null)
throw new ArgumentNullException("member");
PropertyDefinition prop = member as PropertyDefinition;
if (prop != null)
return ChkPropertyVisible(prop);
FieldDefinition field = member as FieldDefinition;
if (field != null)
return ChkFieldVisible(field);
return false;
}
}

private static bool GetCheckVisible(IMemberDefinition member)
{
if (member == null)
throw new ArgumentNullException("member");
PropertyDefinition prop = member as PropertyDefinition;
if (prop != null)
return ChkPropertyVisible(prop);
FieldDefinition field = member as FieldDefinition;
if (field != null)
return ChkFieldVisible(field);
return false;
}

private static bool ChkPropertyVisible(PropertyDefinition property)
{
MethodDefinition method;
bool get_visible = false;
bool set_visible = false;
if ((method = property.GetMethod) != null &&
(DocUtils.IsExplicitlyImplemented(method) ||
(!method.IsPrivate && !method.IsAssembly && !method.IsFamilyAndAssembly)))
get_visible = true;
if ((method = property.SetMethod) != null &&
(DocUtils.IsExplicitlyImplemented(method) ||
(!method.IsPrivate && !method.IsAssembly && !method.IsFamilyAndAssembly)))
set_visible = true;
if ((set_visible == false) && (get_visible == false))
return false;
else
return true;
{
MethodDefinition method;
bool get_visible = false;
bool set_visible = false;

if ((method = property.GetMethod) != null &&
(DocUtils.IsExplicitlyImplemented(method) ||
(!method.IsPrivate && !method.IsAssembly && !method.IsFamilyAndAssembly)))
get_visible = true;

if ((method = property.SetMethod) != null &&
(DocUtils.IsExplicitlyImplemented(method) ||
(!method.IsPrivate && !method.IsAssembly && !method.IsFamilyAndAssembly)))
set_visible = true;

if ((set_visible == false) && (get_visible == false))
return false;
else
return true;
}

private static bool ChkFieldVisible(FieldDefinition field)
{
TypeDefinition declType = (TypeDefinition)field.DeclaringType;
if (declType.IsEnum && field.Name == "value__")
return false; // This member of enums aren't documented.
return field.IsPublic || field.IsFamily || field.IsFamilyOrAssembly;
{
TypeDefinition declType = (TypeDefinition)field.DeclaringType;

if (declType.IsEnum && field.Name == "value__")
return false; // This member of enums aren't documented.

return field.IsPublic || field.IsFamily || field.IsFamilyOrAssembly;

}

}
internal static class NBoolExtensions
{
public static bool IsTrue (this Nullable<bool> value) =>
value.HasValue && value.Value;
}
internal static class NBoolExtensions
{
public static bool IsTrue (this Nullable<bool> value) =>
value.HasValue && value.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void RemoveDragOverHandler(DependencyObject element, DragEventHand
}
#endregion

#region docs.microsoft.com example
#region learn.microsoft.com example
public static readonly RoutedEvent NeedsCleaningEvent;
public static void AddNeedsCleaningHandler(DependencyObject d, RoutedEventHandler handler)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AttachedEventsAndProperties
{
public static class AttachedPropertyExample
{
#region modified docs.microsoft.com example
#region modified learn.microsoft.com example

public static readonly DependencyProperty IsBubbleSourceProperty = DependencyProperty.RegisterAttached(
"IsBubbleSource",
Expand Down
2 changes: 2 additions & 0 deletions mdoc/mdoc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

<PropertyGroup Condition=" '$(TargetFramework)' != 'net471' ">
<OutputPath>$(MSBuildThisFileDirectory)..\bin\$(Configuration)-$(TargetFramework)</OutputPath>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion mdoc/mdoc.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
</metadata>
<files>
<file src="..\bin\Release\*.*" target="tools\net471\" />
<file src="..\bin\Release-net6.0\*.*" target="tools\net6.0\" />
<file src="..\bin\Release-net6.0\win-x64\*.*" target="tools\net6.0\" />
</files>
</package>